On Wed, 24 Feb 2010, Ciaran McCreesh wrote:
> On Mon, 25 Jan 2010 03:01:22 -0500 (EST) "Benjamin R. Haskell"
> <[email protected]> wrote:
> > At some point, Ciaran McCreesh wrote:
> >
> > > I suspect the real problem is that the daemon doesn't fork itself
> > > twice, to make itself owned by init rather than the spawning
> > > process.
> >
> > ...the daemon spawned by distcc -j appears to not double-fork, but
> > it does setsid(). And, the attached program triggers the same
> > behavior w.r.t. outputwrapper, unless called with the
> > with-closed-fds wrapper from my initial email.
> > (double-forked-simple.c just double forks, closes fd's 0-2,
> > setsid()s, and sleeps for 20 seconds.) But maybe I'm missing
> > something the 'distcc' code misses, too.
>
> Sessions are something else. They're not related to reparenting.
Interesting. I've not done a ton of work with low-level forking/etc, so
I didn't fully comprehend that.
Nonetheless, the program I attached before still demonstrates the
problem, even with double-forking. And attached is an even more minimal
program that demonstrates the problem.
Compile: gcc -Wall -o minimal-double-fork{,.c}
Testing: (one line)
PALUDIS_EBUILD_DIR=/usr/libexec/paludis
/usr/libexec/paludis/utils/outputwrapper --stdout-prefix 'stdout> '
--stderr-prefix 'stderr> ' -- ./minimal-double-fork
If the 'i<3' in the program is changed to 'i<30', the pause disappears.
Sorry to beat a dead horse, but at this point I'm mostly curious for
future reference.
--
Best,
Ben#include <unistd.h>
#include <sys/wait.h>
int main(void) {
int i;
pid_t w;
if ((w = fork())) waitpid(w, NULL, 0);
else if (!fork()) {
for (i=0; i<3; i++) close(i);
setsid();
sleep(20);
}
return 0;
}
_______________________________________________
paludis-user mailing list
[email protected]
http://lists.pioto.org/mailman/listinfo/paludis-user