Subject: Re: Process gets SIGHUP at end of boot
To: Luke Mewburn <>
From: Rick Byers <>
List: netbsd-users
Date: 07/06/2001 12:18:36
On Thu, 17 May 2001, Luke Mewburn wrote:

> > I'm using the rp-pppoe package, and run adsl-start in an rc
> > script.  Everything works great, except that once the bootup sequence is
> > complete, the pppoe process gets a SIGHUP signal and is restarted:
> >
> > I could easily just modify the pppoe program to ignore sighup, but I'd
> > like to know whats causing it.
> It's caused because the pppoe program doesn't detach itself from
> /dev/console once it starts up. You can solve this by adding a line in
> the source code to call something like:
> 	daemon(0,0);
> to detach from the controlling tty.
> When init finishes running /etc/rc, it sets up the ttys as described
> in init(8), state 3. As part of the setting up the ttys, init(8) sends
> a SIGHUP to the controlling process for each tty which is marked as
> `off'.
> I'm guessing that your problem occurs because the system boots using
> /dev/console for the device for /etc/rc, and when init(8) goes into
> state 3 to setup ttys, /etc/ttys has /dev/console being `off' and
> /dev/ttyE0 (first wscons terminal) being `on', so the controlling
> processes left on /dev/console (which might be the last thing
> attached (???), in this case pppoe) get a SIGHUP.
> There's probably a much better explanation, but that's what I think
> is happening. It's definitely init(8)'s dirty work, not rc(8)s.

I finally spent some time to look into this further.  I found that the
signal gets sent regardless of the contents of /etc/ttys (I tried about 20
configurations, everyhing "on", entires just commented out etc..).  I
added a whole bunch of debugging messages and delays to init and found
that it doesn't appear to be init sending the SIGHUP (it never goes into
"clean_ttys" which is the only function that sends a SIGHUP).  The SIGHUP
appears to be received while init is in waitpid waiting to collect the
exit status of /etc/rc.  waitpid returns an exit status of 0 for some
process (not sure what - not an init session) and about that same time my
pppoe process complains of getting a SIGHUP.  There is no chance for
anything in init to run that could cause the SIGHUP.  Then after a few
seconds delay init's waitpid returns the status of /etc/rc finishing and
things proceed from there.

Could the shell (started for /etc/rc) be sending a SIGHUP to all child
processes when it exits?

Is there something going on with the terminal driver that I'm not aware
of?  Who else could be sending the SIGHUP?  In addition to pppoe, I also
have problems with mysqld - sometimes (but not allways) it gets killed at
the end of the boot sequence.  Apparently mysql instals its own SIGHUP
handler, but not allways soon enough.  I've tried setting SIGHUP to ignore
in the shell script that starts mysql, but that doesn't help.

Any other idea of how I could track this down?  After spending a few hours
hacking around with init, I'm pretty confident its not coming from there.