:: Re: [DNG] Doing away with multi-thr…
Top Pagina
Delete this message
Reply to this message
Auteur: Rainer Weikusat
Datum:  
Aan: dng
Onderwerp: Re: [DNG] Doing away with multi-threading in my project (netman)
Edward Bartolo <edbarx@???> writes:
> A periodic algorithm is now implemented in the frontend to search for
> backend and any spawned children for ownership by root. This most
> probably was what was causing waitpid and wait to fail to reap
> zombies.


It can't. As an experiment, copy the id program to /tmp and make it
setuid-0:

As root, run

cp /usr/bin/id /tmp
cd /tmp
chmod u+s id

Compile and run the following program in /tmp (as non-root user):

------
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>

int main(void)
{
    int status;


    if (fork() == 0) execl("/tmp/id", "id", (void *)0);


    wait(&status);
    fprintf(stderr, "exit status %d\n", status);


    sleep(2);
    execlp("/bin/ps", "ps", "fax", (void *)0);


    return 0;
}
------


This will print 'exit status 0', sleep for 2s and then display the ps
fax process with no zombie attached to it. Repeat running the program
but after recompiling it with the wait and fprintf lines commented
out. This time, the ps fax output will show the 'defunct' id process as
it's exit status hasn't been collected.

There's of course a chance that the fpc libraries do something funky for
such a case but I don't believe so.