devfs
[Top] [All Lists]

setsid() and new sysvinit

To: devfs@xxxxxxxxxxx
Subject: setsid() and new sysvinit
From: Russell Coker <russell@xxxxxxxxxxxx>
Date: Mon, 22 Oct 2001 22:32:39 +0200
Reply-to: Russell Coker <russell@xxxxxxxxxxxx>
Sender: owner-devfs@xxxxxxxxxxx
Firstly I just noticed that devfsd is not calling setsid() after doing 
close(0);close(1);close(2); is there a good reason for this or is it an 
oversight?  It is my understanding that all daemons should call setsid()...

I came across this while investigating a problem that occurs with the latest 
sysvinit package in Debian.  Sysvinit now makes /dev/console the controlling 
terminal for daemons started before multi-user mode is initiated.  This means 
that it will be sent a SIGHUP by the kernel when the session ends (IE 
multi-user mode is started).

The SIGHUP results in the configuration reload which displays annoying error 
messages to the console.

With the current way devfsd works the console is kept open until /dev/log is 
created, at which time openlog() is called and the stdin/stdout/stderr are 
closed.

But the session is ended before syslogd is started.

What can we do about this?  Would it be a good idea to do 
close(0);close(1);close(2); at the start of the program and then 
open("/dev/console", O_WRONLY|O_NOCTTY); ?

Of course if you want to start devfsd on some other device and have all the 
error messages go there before syslogd is started and not have the messages 
go there then this won't be what you want.

-- 
http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page

<Prev in Thread] Current Thread [Next in Thread>
  • setsid() and new sysvinit, Russell Coker <=