pgrp = getpid();
if(setpgid(0, pgrp) < 0)
err(1, "setpgid");
This appears to me a program trying to deemonize itself (in the old style
when there was only job control but no session management).
In the case this program is already properly daemonized, e.g. by starting
it from /usr/sbin/daemon, this code now fails, invoking the err() clause
and thereby aborting.
From what I could find out, POSIX does not allow a session leader to do
setpgid() on itself.
When a program is invoked via /usr/sbin/daemon, it should already be
session leader AND group leader, and then the above code WOULD be a NOOP,
unless POSIX would require the setpgid() to fail and thereby the program
to abort - which, btw, is NOT a NOOP :(
So, where is the mistake here?
Option 1: I have completely misunderstood something. Then please tell me
what.
Option 2: The quoted code is bogus. Then why is it in base?
option 3: The setpgid() behaviour is bogus. It may stop a session leader
from executing it, but it should detect a NOOP and just go thru with it.
Then why don't we fix that?
Option 4: POSIX is bogus. Unlikely, because as far as I could find out,
that part of it was written following the Berkeley implementation.
_______________________________________________
freebsd-stable@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"