Re: NSTask stealth bug in readDataOfLength!! :(
Re: NSTask stealth bug in readDataOfLength!! :(
- Subject: Re: NSTask stealth bug in readDataOfLength!! :(
- From: "Stephen Deken" <email@hidden>
- Date: Wed, 25 Oct 2006 13:17:43 -0500
Lesson learnt? NEVER USE NSTASK! It sucks. I used system() instead :(
I'm pretty sure that NSTask doesn't suck, and that you're just
incorrectly using a perfectly good API. I've had no problems using
NSTask in this way:
process = [[NSTask alloc] init];
[process setLaunchPath:exec];
[process setCurrentDirectoryPath:[exec stringByDeletingLastPathComponent]];
[process setArguments:args];
[process setEnvironment:env];
[process setStandardError:[NSPipe pipe]];
[process setStandardInput:[NSPipe pipe]];
[process setStandardOutput:[NSPipe pipe]];
[process launch];
NSFileHandle *fh = [[process standardOutput] fileHandleForReading];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(processData:)
name:NSFileHandleReadCompletionNotification object:fh];
[fh readInBackgroundAndNotify];
Note that this is for a long-running process that gets both read from
and written to, but the principle is the same regardless. I can't
reproduce your specific error, but I can attest that there is really
nothing wrong with NSTask. If it's crashing, it's because you're
doing something wrong.
Stephen Deken
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden