httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Bannert <>
Subject Re: Running Apache in the foreground
Date Sat, 29 Dec 2001 01:35:13 GMT
On Fri, Dec 28, 2001 at 05:03:06PM -0800, Jos Backus wrote:
> Interestingly in the Samba code the setsid() call comes _after_ the fork()
> (see my previous e-mail) and that seems to work just fine. So it looks like
> the order suggested is not an absolute requirement; any thoughts on this?

Let me clarify a little:

setsid() MUST be called by a proces that is NOT a process group leader,
else it will fail with -1.

Apache is normally started in two ways: 
1) bin/apachectl
2) bin/httpd

Normally when starting a program from the shell, that program becomes the
process group leader of a new process group. In case #1 the apachectl
script becomes the process leader and httpd becomes it's child (which
will inherit the PGID). This means httpd is NOT a process group leader. In
case #2, httpd IS the process group leader, and hence setsid() will fail.

Therefore the only way to ensure that the calling process is NOT the
process group leader is to call fork() before calling setsid().


View raw message