Subject: Re: Process gets SIGHUP at end of boot
To: Rick Byers <Rickb@BigScaryChildren.net>
From: Luke Mewburn <lukem@wasabisystems.com>
List: netbsd-users
Date: 05/17/2001 22:46:08
On Wed, May 16, 2001 at 11:10:14PM -0400, Rick Byers wrote:
> Hi,
> 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:
> 
> May 16 23:02:39 Apenheul pppd[108]: Child process /usr/pkg/sbin/pppoe -p /var/run/adsl.pid.pppoe -I ne0 -T 80  -m 1412  (pid 112) terminated with signal 1
> May 16 23:02:40 Apenheul adsl-connect: ADSL connection lost; attempting re-connection.
> 
> What would be causing this sighup signal?  Should the adsl scripts be
> dissasociating themselves from the terminal so that they aren't part of
> the terminal group?  I tried adding a 'trap "" 1' to set SIGHUP to be
> ignored but the child pppoe process still got it.
> 
> 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.