Re: NSTask terminates when NSApplication exits
Re: NSTask terminates when NSApplication exits
- Subject: Re: NSTask terminates when NSApplication exits
- From: Kyle Sluder <email@hidden>
- Date: Thu, 19 Jan 2012 09:36:19 -0800
On Wed, Jan 18, 2012 at 12:38 PM, Jens Alfke <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden