Possible bug launching an NSTask from within and NSOperation subclass
Hi there, I've encountered what I believe to be a bug, but I'd like more eyes on it to make sure I'm not doing something wrong. I've set up a simple application, with one controller that has a reference to an NSOperationQueue. When a button is pressed, the controller queues up an NSOperation subclass, which schedules its run loop, then fires off a call to perform an NSTask. The task simply launches /bin/sleep for 2 seconds. You can follow along and try for yourself here: http://github.com/texel/NSOperationDebug Here's the bug– when the NSTask is launched, regardless of whether or not waitUntilExit is set on it, and regardless of whether or not the task actually exits, it seems to block the NSOperation's run loop indefinitely. I had this issue in another application, but this is the most basic case I can think of to reproduce it. If I'm doing something wrong, then awesome. Any help would be appreciated. If not, then I'd be glad to file a bug report. Thanks! Leigh
Hi Leigh, I had a quicklook at the code. I am not sure if running the main runloop from an NSOperation is the right thing to do here, I suspect that's what's causing the problem. It might be interesting to use the NSTask's notification functionality here or try to rewrite this code in pure ObjC and see if the problem persists. Laurent On Jul 19, 2010, at 8:23 PM, Leigh Caplan wrote:
Hi there,
I've encountered what I believe to be a bug, but I'd like more eyes on it to make sure I'm not doing something wrong. I've set up a simple application, with one controller that has a reference to an NSOperationQueue. When a button is pressed, the controller queues up an NSOperation subclass, which schedules its run loop, then fires off a call to perform an NSTask. The task simply launches /bin/sleep for 2 seconds.
You can follow along and try for yourself here: http://github.com/texel/NSOperationDebug
Here's the bug– when the NSTask is launched, regardless of whether or not waitUntilExit is set on it, and regardless of whether or not the task actually exits, it seems to block the NSOperation's run loop indefinitely. I had this issue in another application, but this is the most basic case I can think of to reproduce it.
If I'm doing something wrong, then awesome. Any help would be appreciated. If not, then I'd be glad to file a bug report.
Thanks! Leigh _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
I don't know if that helps but here is an app I wrote using NSTask and working just fine: http://github.com/mattetti/couchdbx-app/tree/master/macruby_version/CouchDBX... NSTask is wrapped to make its use a bit easier: Usage: http://github.com/mattetti/couchdbx-app/blob/master/macruby_version/CouchDBX... Wrapper: http://github.com/mattetti/couchdbx-app/blob/master/macruby_version/CouchDBX... More wrappers: http://github.com/mattetti/MrStuff I hope it helps, - Matt On Mon, Jul 19, 2010 at 8:23 PM, Leigh Caplan <texel1@gmail.com> wrote:
Hi there,
I've encountered what I believe to be a bug, but I'd like more eyes on it to make sure I'm not doing something wrong. I've set up a simple application, with one controller that has a reference to an NSOperationQueue. When a button is pressed, the controller queues up an NSOperation subclass, which schedules its run loop, then fires off a call to perform an NSTask. The task simply launches /bin/sleep for 2 seconds.
You can follow along and try for yourself here: http://github.com/texel/NSOperationDebug
Here's the bug– when the NSTask is launched, regardless of whether or not waitUntilExit is set on it, and regardless of whether or not the task actually exits, it seems to block the NSOperation's run loop indefinitely. I had this issue in another application, but this is the most basic case I can think of to reproduce it.
If I'm doing something wrong, then awesome. Any help would be appreciated. If not, then I'd be glad to file a bug report.
Thanks! Leigh
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Laurent Sansonetti
-
Leigh Caplan
-
Matt Aimonetti