• 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 & Quitting Processes ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask & Quitting Processes ...


  • Subject: Re: NSTask & Quitting Processes ...
  • From: Michael Ash <email@hidden>
  • Date: Wed, 8 Apr 2009 10:14:03 -0400

On Wed, Apr 8, 2009 at 9:33 AM, Mic Pringle <email@hidden> wrote:
> Hi,
>
> If I launch a process using NSTask, in this case a lightweight
> webserver, will that process terminate when I close my application, if
> the process is still alive ?
>
> When I currently launch the server from the terminal, it only quits
> when I hit ctrl + c.

It will not automatically terminate when your application quits.
However, quitting your application will close any pipes share with the
subprocess. This will often cause a process to quit. For example, many
processes terminate when their standard input is closed. Many pipes
also regularly write to their standard output, and if closed, this
will send a SIGPIPE where the default behavior is to terminate the
process.

So basically, if your subprocess's stdin is a pipe and it terminates
when that pipe is closed, or if your subprocess's stdout/stderr is a
pipe and it writes to them regularly (and doesn't trap SIGPIPE), then
it will quit when or soon after your application quits. Otherwise it
won't.

Mike
_______________________________________________

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

References: 
 >NSTask & Quitting Processes ... (From: Mic Pringle <email@hidden>)

  • Prev by Date: Re: Need localization-proof method of transporting dates.
  • Next by Date: Re: Cocoa-dev Digest, Vol 6, Issue 545
  • Previous by thread: NSTask & Quitting Processes ...
  • Next by thread: Re: Cocoa-dev Digest, Vol 6, Issue 545
  • Index(es):
    • Date
    • Thread