Re: How to assure NSTask termination when parent dies
Re: How to assure NSTask termination when parent dies
- Subject: Re: How to assure NSTask termination when parent dies
- From: Greg Guerin <email@hidden>
- Date: Fri, 13 Aug 2010 14:32:22 -0700
Process group code:
// launch the task
[task launch];
pid_t group = setsid();
if (group == -1) {
NSLog(@"setsid() == -1");
group = getpgrp();
}
if (setpgid([task processIdentifier], group) == -1) {
NSLog(@"unable to put task into same group as self:
errno = %i", errno);
}
The current process-group id is inherited across fork() and execve()
- see their respective man pages. So if you reorder the operations
so setsid() occurs before [task launch], then the child inherits
automatically.
This doesn't mean the child can't change its own pgid/sid. And since
you mention a shell, it's not unusual for shells to do exactly that.
-- GG
_______________________________________________
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