[MacRuby-devel] macruby NSTask problem
Alex Greif
alex at greifdesign.net
Sun Oct 9 00:58:14 PDT 2011
here an update:
the problem seems to be with the notifier, because if I use the following
code without the NSNotificationCenter, then, everything works fine, like
the following sample code:
task = NSTask.alloc.init
task.currentDirectoryPath = "/"
task.launchPath = "/bin/bash"
task.arguments = ["some script"]
stdout_pipe = NSPipe.pipe
task.setStandardOutput stdout_pipe
stdout_file_handle = stdout_pipe.fileHandleForReading
task.launch
task.waitUntilExit
exit_status = task.terminationStatus
stdout_data = stdout_file_handle.readDataToEndOfFile
stdout = NSString.alloc.initWithData(stdout_data,
encoding:NSUTF8StringEncoding)
Does anybody have such bad experiences with the NSNotificationCenter?
ALex.
> Hi
>
> I tried the subprocess sample with the AsyncHandler from
> http://ofps.oreilly.com/titles/9781449380373/_foundation.html
>
> and found the following problem:
> if I execute the code many times (I tried 20 times) in my terminal with
> $ macruby sample.rb
> then 2-3 times it does not print any output. In this 10% the data_ready:
> method of the AsyncHandler is not called.
>
> Is this a macruby problem or an NSTask problem?
>
> BTW using NSFileHandleReadToEndOfFileCompletionNotification instead of
> NSFileHandleReadCompletionNotification makes it even worse, in this case
> data_ready: is never called.
>
> I use the 2011.09.27 macruby 0.11 snapshot
> and mac os x 10.6.8
>
> Alex.
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
More information about the MacRuby-devel
mailing list