Re: NSTask & Quitting Processes ...
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