• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTask terminates when NSApplication exits
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask terminates when NSApplication exits


  • Subject: Re: NSTask terminates when NSApplication exits
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 18 Jan 2012 15:27:57 -0600

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?

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?

> 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).

> 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.

Regards,
Ken

_______________________________________________

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

  • Follow-Ups:
    • Re: NSTask terminates when NSApplication exits
      • From: Keary Suska <email@hidden>
    • Re: NSTask terminates when NSApplication exits
      • From: Scott Ribe <email@hidden>
References: 
 >NSTask terminates when NSApplication exits (From: Andrew <email@hidden>)
 >Re: NSTask terminates when NSApplication exits (From: Keary Suska <email@hidden>)

  • Prev by Date: Re: NSTask terminates when NSApplication exits
  • Next by Date: Re: NSTask terminates when NSApplication exits
  • Previous by thread: Re: NSTask terminates when NSApplication exits
  • Next by thread: Re: NSTask terminates when NSApplication exits
  • Index(es):
    • Date
    • Thread