On Jan 18, 2012, at 2:27 PM, Ken Thomases wrote:

> On Jan 18, 2012, at 3:13 PM, Keary Suska wrote:
> 
>> Any special handling of NSTask aside, Mac OS X uses Unix-based process 
>> control which closes all child processes when the parent is closed.
> 
> No, that's not true.  Where did you get that?

It has likely, as you point out, come from the entirely wrong orifice. I 
suspect I am confusing tis with system() and popen() calls, which I think have 
a dependency on the parent process' life, but I could be wrong about that too.

> Processes with a controlling terminal get a SIGHUP when that terminal is 
> closed, and that will kill a naive process, but that wouldn't apply to 
> subprocesses of GUI apps.  Other than that, child processes are independent 
> of their parent process.
> 
>> Since your sub-program is Java you may be able to detach the child process.
> 
> This doesn't make sense to me.  What does being Java have to do with anything?

I meant as opposed to a Cocoa-based app. The Java runtime, AFAIK, does not have 
the same restrictions.

>> This is usually accomplished by the sub-program by executing a low-level 
>> fork(). It may need to be followed by an exec() to fully detach the process.
> 
> Fork() creates the child subprocess as a near duplicate of the parent.  
> Exec() replaces the process's image with a new one.  This is the standard 
> means of creating a subprocess running a new program, but doesn't 
> particularly "detach" an already-existing subprocess from its parent 
> (whatever that might mean).

Again, this might be my mistaking daemonizing pipe-to-subprocess, but I could 
be wrong about that too. 

>> Note that you can't do this with Cocoa/Objective-C (at least Apple says you 
>> shouldn't…)
> 
> You can fork() and exec() just fine.  What you can't do is fork(), _not_ call 
> exec(), and then do anything other than call POSIX async-cancel-safe APIs.  
> That includes using high-level frameworks like Cocoa, Core Foundation, or the 
> like.

This might also be where I recalled the necessity of fork-exec, but it has been 
some time since I wandered down that rabbit hole..

Sorry for the noise...

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to