NSTask -launch/+launchedTaskWithPath:... - externally retained for life of task?
NSTask -launch/+launchedTaskWithPath:... - externally retained for life of task?
- Subject: NSTask -launch/+launchedTaskWithPath:... - externally retained for life of task?
- From: Jim Correia <email@hidden>
- Date: Tue, 3 Mar 2009 23:38:40 -0500
Suppose you have the following code, running in either retain/release
land or GC land (ends up the behavior is similar because of the
autorelease pool or collector after return):
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/sleep"];
[task setArguments: [NSArray arrayWithObjects: @"10", nil]];
[task launch];
[task autorelease];
- or -
NSArray *args = [NSArray arrayWithObjects: @"10", nil];
[NSTask launchedTaskWithLaunchPath: @"/bin/sleep" arguments: args];
Is it guaranteed that the task will be externally retained/rooted for
the life of the task?
In a simple test program (and by tracing execution in the debugger)
that appears to be the case. But I cannot find this guarantee in the
documentation.
In fact, what I do see in the docs for NSTaskDidTerminateNotification
actually suggests the opposite. It says:
Posted when the task has stopped execution. This notification can be
posted either when the task has exited normally or as a result of
terminate being sent to the NSTask object. If the NSTask object gets
released, however, this notification will not get sent, as the port the
message would have been sent on was released as part of the task
release.
Can anyone provide clarification?
- Jim
_______________________________________________
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