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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to