[NSTask] -launch return
[NSTask] -launch return
- Subject: [NSTask] -launch return
- From: Erg Consultant <email@hidden>
- Date: Tue, 9 Jun 2009 01:56:37 -0700 (PDT)
I need to launch and execute a task via NSTask and then immediately get both notification that it launched, and it's launched pid.
I tried the notification mechanism but it requires that I first return from my launch function and let the even loop run in order to receive the notification. If there some other way to get the notification immediately after launch. I tried the following:
// Make params array...
launchTaskParams = [ [ NSArray alloc ] initWithArray:[ NSArray arrayWithObject:finalPathMutableNSString ] ];
// Make task...
launchTask = [ [ NSTask alloc ] init ];
if( launchTask && launchTaskParams )
{
// Set arguments & path...
[ launchTask setArguments:launchTaskParams ];
[ launchTask setLaunchPath:finalPathMutableNSString ];
// Launch!
[ launchTask launch ];
// Wait 'til is running...
while( ![ launchTask isRunning ] )
{
; // Spin
}
// Set pid in output...
lppiProcInfo->dwProcessId = (DWORD)[ LaunchTask processIdentifier ];
NSLog( @"PID is: @%", [ [ NSNumber numberWithInt:[ LaunchTask processIdentifier ] ] stringValue ] );
// Release the LaunchTask & params so they can be used next time...
[ launchTask release ];
[ launchTaskParams release ];
}
_______________________________________________
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