Re: Terminating subtasks reliably
Re: Terminating subtasks reliably
- Subject: Re: Terminating subtasks reliably
- From: Dave Keck <email@hidden>
- Date: Thu, 1 Apr 2010 13:19:28 -1000
>> Look like a race condition. The man page says getppid() will not fail, but
>> not what happens after the parent dies. I will test this.
>
> If the parent dies, the process becomes the child of launchd. For a quick
> fix I checked for the parent PID greater than 1.
>
> A better fix, the parent process passed its PID to the child process as an
> argument. In the child process, if getppid() does not return the PID from
> the parent process, exit.
Another problem is if the parent dies after the getppid(), and another
process starts with the same PID as the old parent, all before the
call to kevent(). In this scenario you'll now be waiting for an
unrelated process to die. This situation is likely impossible
currently with incrementing PIDs, but there's been mention of PID
randomization on darwin-dev:
http://lists.apple.com/archives/darwin-dev/2009/Oct/msg00056.html
I only mention this because I use this kevent method to detect a
parent's death, and have been looking for a better technique that
also doesn't require the parent's cooperation...
_______________________________________________
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