Re: Terminating subtasks reliably

2010-04-04 Thread Scott Ribe
> Why not have the parent call setsid() / setpgid() at the beginning? IIRC, odd things happen if a GUI app is not in the Login Window's process group... -- Scott Ribe scott_r...@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice ___ Co

Re: Terminating subtasks reliably

2010-04-04 Thread Julian Hsiao
Why not have the parent call setsid() / setpgid() at the beginning? This should prevent the PID from getting recycled until every process in the process group exits. Julian Hsiao mad...@nyanisore.net On Apr 2, 2010, at 8:10 PM, Michael Ash wrote: > On Thu, Apr 1, 2010 at 7:19 PM, Dave Keck w

Re: Terminating subtasks reliably

2010-04-03 Thread Dave Keck
> Call getppid, set up the kevent listener, then before you actually > block in kevent, call getppid *again*. If the answer matches the first > call, then you can go ahead and call kevent. If the answer doesn't > match, you've hit the race condition you outline here, your parent is > dead, and you

Re: Terminating subtasks reliably

2010-04-02 Thread Michael Ash
On Thu, Apr 1, 2010 at 7:19 PM, Dave Keck wrote: >>> 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 par

Re: Terminating subtasks reliably

2010-04-01 Thread Dave Keck
>> 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 pr

Re: Terminating subtasks reliably

2010-03-31 Thread John Harte
On Mar 31, 2010, at 9:13 AM, John Harte wrote: What does getppid() returns if the parent dies before the child reach this point ? 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,

Re: Terminating subtasks reliably

2010-03-31 Thread John Harte
On Mar 31, 2010, at 4:28 AM, Jean-Daniel Dupas wrote: > > What does getppid() returns if the parent dies before the child reach this > point ? > 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. Thanks John

Re: Terminating subtasks reliably

2010-03-31 Thread Jean-Daniel Dupas
Look at the sources. It uses kevent. (man kevent) Le 31 mars 2010 à 14:24, McLaughlin, Michael P. a écrit : > How does WatchForTermination() do its watching? Is it constantly polling? > That would be a performance-killer. > > > On 3/30/10 11:18 PM, "John Harte" wrote: > > > > On Mar 30,

Re: Terminating subtasks reliably

2010-03-31 Thread McLaughlin, Michael P.
How does WatchForTermination() do its watching? Is it constantly polling? That would be a performance-killer. On 3/30/10 11:18 PM, "John Harte" wrote: On Mar 30, 2010, at 4:01 PM, McLaughlin, Michael P. wrote: > I have a Cocoa app (Leopard) which launches several Foundation Tool subtasks

Re: Terminating subtasks reliably

2010-03-31 Thread Jean-Daniel Dupas
Le 31 mars 2010 à 05:18, John Harte a écrit : > > On Mar 30, 2010, at 4:01 PM, McLaughlin, Michael P. wrote: > >> I have a Cocoa app (Leopard) which launches several Foundation Tool subtasks >> (since threads are not sufficient in this case). Currently, I terminate >> these subtasks via the ap

Re: Terminating subtasks reliably

2010-03-30 Thread John Harte
On Mar 30, 2010, at 4:01 PM, McLaughlin, Michael P. wrote: > I have a Cocoa app (Leopard) which launches several Foundation Tool subtasks > (since threads are not sufficient in this case). Currently, I terminate > these subtasks via the app-delegate method > > -(NSApplicationTerminateReply)appl

Re: Terminating subtasks reliably

2010-03-30 Thread A.M.
On Mar 30, 2010, at 4:01 PM, McLaughlin, Michael P. wrote: > I have a Cocoa app (Leopard) which launches several Foundation Tool subtasks > (since threads are not sufficient in this case). Currently, I terminate > these subtasks via the app-delegate method > > -(NSApplicationTerminateReply)appl

Re: Terminating subtasks reliably

2010-03-30 Thread Greg Parker
On Mar 30, 2010, at 1:01 PM, McLaughlin, Michael P. wrote: > I have a Cocoa app (Leopard) which launches several Foundation Tool subtasks > (since threads are not sufficient in this case). Currently, I terminate > these subtasks via the app-delegate method > > -(NSApplicationTerminateReply)applic

Re: Terminating subtasks reliably

2010-03-30 Thread Jeff Johnson
Hi Mike. How about having the main app periodically post a notification via NSDistributedNotificationCenter? The subtasks can observe the notification and terminate themselves if they don't receive one for some period of time. -Jeff On Mar 30, 2010, at 3:01 PM, McLaughlin, Michael P. wrote:

Terminating subtasks reliably

2010-03-30 Thread McLaughlin, Michael P.
I have a Cocoa app (Leopard) which launches several Foundation Tool subtasks (since threads are not sufficient in this case). Currently, I terminate these subtasks via the app-delegate method -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender This works provided one