Re: NSTask terminates when NSApplication exits (Scott Ribe)

2012-01-20 Thread lpeng...@gmail.com
Re: NSTask terminates when NSApplication exits (Scott Ribe) Ling Peng 在 2012年1月19日,4:02,cocoa-dev-requ...@lists.apple.com 写道: > Re: NSTask terminates when NSApplication exits (Scott Ribe) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Ple

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Scott Ribe
On Jan 19, 2012, at 11:49 AM, Jens Alfke wrote: > Huh; you learn something new every day! Yeah, specifically I learned this about 6 months ago ;-) > In addition to shell behavior you mention, I also see this when Xcode crashes > and takes down the app I’m debugging. But I suppose Xcode configur

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Ken Thomases
On Jan 19, 2012, at 12:49 PM, Jens Alfke wrote: > On Jan 19, 2012, at 10:10 AM, Scott Ribe wrote: > >> Not true. It looks like the case at a cursory level because session >> management does this when you're in the terminal. There are various ways to >> arrange for a process to exit when its par

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Jens Alfke
On Jan 19, 2012, at 10:10 AM, Scott Ribe wrote: > Not true. It looks like the case at a cursory level because session > management does this when you're in the terminal. There are various ways to > arrange for a process to exit when its parent exits. But it is *not* the case > that a process i

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Scott Ribe
On Jan 18, 2012, at 1:38 PM, Jens Alfke wrote: > > Nope. In Unix, a process is killed when its parent process exits. Not true. It looks like the case at a cursory level because session management does this when you're in the terminal. There are various ways to arrange for a process to exit whe

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Keary Suska
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

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Kyle Sluder
On Wed, Jan 18, 2012 at 12:38 PM, Jens Alfke wrote: > Nope. In Unix, a process is killed when its parent process exits. No it's not. /tmp% cat processes.c #include #include int main(int argc, char **argv) { printf("Parent pid is %lu\n", (unsigned long)getpid()); pid_t child = fork();

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Jens Alfke
On Jan 18, 2012, at 10:59 AM, Andrew wrote: > I am trying to write a program that maintains different installs of > another program including launching the program. To do so, I am using > NSTask. Now when I quit my cocoa app. the NSTask app dies. … > According to what I have read, the applicatio

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Scott Ribe
On Jan 18, 2012, at 2:27 PM, Ken Thomases wrote: >> 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

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Andrew
Thanks, I'll have a look. BTW, I was able to confirm it is a result of streams. My Java processes do not quit if I pipe their output to null:  NSTask *task = [NSTask new];  [task setLaunchPath:execPath];  [task setCurrentDirectoryPath:_directory];  [task setArguments:arguments];  [task setStandard

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Ken Thomases
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 th

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Keary Suska
On Jan 18, 2012, at 11:59 AM, Andrew wrote: > I am trying to write a program that maintains different installs of > another program including launching the program. To do so, I am using > NSTask. Now when I quit my cocoa app. the NSTask app dies. The task > that the NSTask is running is a Java pro

Re: NSTask terminates when NSApplication exits

2012-01-18 Thread Scott Ribe
On Jan 18, 2012, at 11:59 AM, Andrew wrote: > I can probably find out the answer by trying different things, but I'd > like to get a better insight for what is going on and why the child > task is terminating. You may want to try LS (Launch Services) routines. -- Scott Ribe scott_r...@eleva

NSTask terminates when NSApplication exits

2012-01-18 Thread Andrew
I am trying to write a program that maintains different installs of another program including launching the program. To do so, I am using NSTask. Now when I quit my cocoa app. the NSTask app dies. The task that the NSTask is running is a Java program, not sure if that makes a difference. According