[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#357561: use setsid() to detach from controlling tty

Package: apache
Version: 1.3.34-2

i'm not sure i understand the motivation behind patch 033_-F_NO_SETSID ... 

the problem in #244857 is a result of the following behaviour of

	On error, -1 is returned, and errno is set.  The only error
	which can happen is EPERM. It is returned  when  the  process
	group ID of any process equals the PID of the calling process.
	Thus, in particular, setsid() fails if the calling process is
	already a process group leader.

the user invoked "apache -F" which doesn't fork() before attempting
setsid() ... this fails with EPERM... and apache foolishly exits.

the real fix is to just warn on that error from setsid() and continue.

the fix that's currently in debian apache (use setpgrp()) leaves apache
with a controlling tty... which is a bad thing, see setpgrp(2):

	If a session has a controlling terminal, CLOCAL is not set and
	a hangup occurs, then the session leader is sent a SIGHUP. If
	the session leader exits, the SIGHUP signal will be sent to
	each process in the foreground process group of  the  con-
	trolling terminal.

please consider reverting 033_-F_NO_SETSID and/or allow setsid() to fail
with EPERM when do_detach == 0.


Reply to: