Re: NSTask taking control of my program
Re: NSTask taking control of my program
- Subject: Re: NSTask taking control of my program
- From: John Nairn <email@hidden>
- Date: Fri, 26 Sep 2003 10:35:29 -0600
On Friday, September 26, 2003, at 06:56 AM,
email@hidden wrote:
I'm doing some work with NSTask, and something does not seem to be
working how I expected it should. From my own understanding, and even
after reading through some of Apple's websites on NSTask, it seems
that when an NSTask is launched, it is its own process. And if it is
its own separate process from the parent program, shouldn't it run
separately, and not necessarily affect the parent? In my program,
when I run the task, I want to have a Cancel/Stop option to terminate
the task if I wish, however, when the program was running, I couldn't
click on any buttons to kill the task. It seems that the task has
taken control over the parent application, stopping any further
interaction until the task is complete.
What might I be missing here, or is my concept of what the NSTask is
doing skewed?
I use NSTask in many application and never have that problem. I also
have no need to launch task in separate thread as another comment
mentioned. In brief, I have a generic task wrapper. It has a method to
start the process which sets the arguments, registers for some
notifications to get output from the task and ends by calling [task
launch]. When this method is done the main application has control
while the task is running as a separate process.
My task wrapper was based on Apple's Moriarity example. I found,
however, that that example had a few problems most troublesome was with
reliably detecting the end of the task and getting everything from
standard output and standard error. I fixed that problem with the help
of AMShellWrapper code written by Andeas Mayer.
See
http://www.harmless.de/cocoa.html for download of AMShellWrapper
and link to Moriarity code too.
------------
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
Web page:
http://www.eng.utah.edu/~nairn
_______________________________________________
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.