• 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
Re: NSTask vs. popen vs. System
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask vs. popen vs. System


  • Subject: Re: NSTask vs. popen vs. System
  • From: Chris Kane <email@hidden>
  • Date: Thu, 5 Dec 2002 10:08:58 -0800

It is a somewhat better wait mechanism from the point of view of an application, because the run loop is run during the wait, which can let user input events come in. Of course, there will be people who don't want that, but they can just do
while ([task isRunning]) <optional delay here of your own choosing>;

Chris Kane
Cocoa Frameworks, Apple


On Tuesday, December 3, 2002, at 06:00 PM, Jeff Disher wrote:

If that is the case then you could use:
[task waitUntilExit];

to block until the receiving task terminates. This also lets you launch the task, perform other operations while it runs, then block before the part of your code that requires the result of the task.

Note, however, that this is no better than system or popen when it comes to waiting for your system to return to another state. For example, certain disk mount/unmount operations are performed by command line programs asynchronously. I only mention that because I was really annoyed with NSTask not waiting for something to terminate after I sent it that message. I later found out that it was waiting for it to terminate but the command line app I was running had invoked the system call in some asynchronous way.

Hope that helps,
Jeff.


On Tuesday, December 3, 2002, at 08:46 PM, matt neuburg wrote:

On Tue, 03 Dec 2002 18:19:26 +0000, Chris Ridd <email@hidden> said:

Both popen and system execute the process using sh, so the arguments you
pass have to be properly quoted and escaped. This is easy to do wrong (hello
iTunes installer :-) and generally it is easier to just use NSTask.

But I think what the O.P. wants to know is how you would you use NSTask synchronously (i.e. your app should block until the result is completely in). m.

matt neuburg, phd = email@hidden, http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


Jeff Disher
President and Lead Developer of Spectral Class
Spectral Class: Shedding Light on Innovation
http://www.spectralclass.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: problem with Textfields
  • Next by Date: stderr output from debugged app in PB
  • Previous by thread: Re: NSTask vs. popen vs. System
  • Next by thread: Maximum size of an NSMutableData object?
  • Index(es):
    • Date
    • Thread