On Wed, Jan 18, 2012 at 12:38 PM, Jens Alfke <j...@mooseyard.com> wrote:
> Nope. In Unix, a process is killed when its parent process exits.

No it's not.

/tmp% cat processes.c
#include <unistd.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    printf("Parent pid is %lu\n", (unsigned long)getpid());

    pid_t child = fork();
    if (child == -1) {
        fprintf(stderr, "Fork failed\n");
        return 1;
    } else if (child == 0) {
        sleep(10000);
        return 0;
    } else {
        printf("Child pid is %lu, parent exiting\n", (unsigned long)child);
        return 0;
    }
}
/tmp% clang -o processes processes.c
/tmp% ./processes
Parent pid is 47549
Child pid is 47550, parent exiting
/tmp% ps aux 47549
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
/tmp% ps aux 47550
USER   PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
kyle 47550   0.0  0.0  2434784    160 s000  S     9:34AM   0:00.00 ./processes

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to