Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Elegant

Name: Anonymous 2008-05-19 11:22

An elegant solution for this:

    /*
    note: the double-fork construct avoids zombie processes
    and keeps the code clean from stupid signal handlers.
    */

    ...
    if(fork() == 0) {
        if(fork() == 0) {
            ..
            execl(pp, pp, (char*) NULL);
            _exit(0);
        }
        _exit(0);
    }
    wait(NULL);
    ..

Thanks

Name: Anonymous 2008-05-19 11:58

>>5
I understand the problem, I need that at PPID of new process /= PID of my process (<=> new parent process = init). I don't know if exist better solution...


And the function _Exit() is equivalent to _exit(), but _exit is in unistd.h and _Exit in stdlib, and I can't use stdlib.h for third reasons...

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List