On 13 Aug 2010, at 22:32, Greg Guerin wrote:
>> 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.
>
Hah! That does seem to have the desired effect.
> 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.
>
In my simple test (one task forks/execs to bash which forks/execs 10 background
sleeps) killing the process leader has the desired cascade of terminations.
Thanks and regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://www.mugginsoft.com_______________________________________________
Cocoa-dev mailing list ([email protected])
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 [email protected]