Re: How to terminate an NSTask whenever my app terminates?

2015-09-01 Thread Jens Alfke
> On Aug 31, 2015, at 11:44 PM, Bavarious wrote: > > There was a 2010 cocoa-dev thread about this: > http://www.lists.apple.com/archives/cocoa-dev/2010/Aug/msg00512.html > Yes, this seems to be what I’m looking for — settin

Re: How to terminate an NSTask whenever my app terminates?

2015-09-01 Thread Scott Ribe
On Aug 31, 2015, at 10:55 PM, Ken Thomases wrote: > > Try the following program. The parent will print the child's PID and exit > (by falling out of main()). Then do a "ps xww -p ". You'll > see the child is still running. You can kill it when satisfied. Yep, I got it backwards. Nothing sp

Re: How to terminate an NSTask whenever my app terminates?

2015-08-31 Thread Bavarious
> On Aug 31, 2015, at 20:32, Jens Alfke wrote: > > (I know this has come up here before, but I can’t get the right combination > of search terms to find an answer…) > > I’m writing a little GUI wrapper app around a command-line-based server. It > uses NSTask to launch the server. I want to en

Re: How to terminate an NSTask whenever my app terminates?

2015-08-31 Thread Ken Thomases
On Aug 31, 2015, at 9:50 PM, Scott Ribe wrote: > > Normally, when a parent exits, all child processes are killed. This is not true. > This is not specific to terminal/tty sessions. Yes, it is. Try the following program. The parent will print the child's PID and exit (by falling out of main(

Re: How to terminate an NSTask whenever my app terminates?

2015-08-31 Thread Michael David Crawford
On the UNIX command line "nohup" prevents children from being killed when the parent exits. If you want to manually start a daemon: $ nohup mydaemon & Then you can log out and it keeps running. -- Michael David Crawford P.E., Consulting Process Architect mdcrawf...@gmail.com http://mike.so

Re: How to terminate an NSTask whenever my app terminates?

2015-08-31 Thread Scott Ribe
Normally, when a parent exits, all child processes are killed. This is not specific to terminal/tty sessions. However, a process can be detached from its parent so that it will survive the parent's exit. I doubt that NSTask does this, but you should verify. Create a dummy helper: int main() {wh

Re: How to terminate an NSTask whenever my app terminates?

2015-08-31 Thread Doug Hill
Hey Jens, I ran across this: Monitoring a Process with a dispatch source "A process dispatch source lets you monitor t

How to terminate an NSTask whenever my app terminates?

2015-08-31 Thread Jens Alfke
(I know this has come up here before, but I can’t get the right combination of search terms to find an answer…) I’m writing a little GUI wrapper app around a command-line-based server. It uses NSTask to launch the server. I want to ensure that when the app exits, the server process exits too. I