• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[NSTask] -launch return
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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

  • Follow-Ups:
    • Re: [NSTask] -launch return
      • From: Michael Ash <email@hidden>
  • Prev by Date: Re: nsdocument application hang ...
  • Next by Date: Re: Replacing a tableView Cell with null
  • Previous by thread: Re: nsdocument application hang ...
  • Next by thread: Re: [NSTask] -launch return
  • Index(es):
    • Date
    • Thread