Run Terminal Scripts from Swift in your Mac app — honza dvorsky http://honzadvorsky.com/blog/2015/5/14/run-terminal-scripts-from-swift-in-a-mac-app …
-
-
@czechboy0 Looks like this doesn't handle the case where the task never terminates because the output pipe buffer gets filled up.0 replies 0 retweets 0 likes -
@mjtsai Good point. How could I do that? The buffer limit is 65536 bytes (OS X pipe buffer size), not sure what happens if overflown :)0 replies 0 retweets 0 likes -
@czechboy0 Build up the output/error data a chunk at a time. Don't -waitUntilExit. Keep running the run loop until file handles are empty.0 replies 0 retweets 0 likes -
@mjtsai But what if the script isn't outputting anything for a while? Wouldn't that terminate before the script itself does?0 replies 0 retweets 0 likes -
@czechboy0 No, because instead of calling -waitUntilExit you run your own loop until the output and error are finished.0 replies 0 retweets 0 likes -
@mjtsai And those are guaranteed to only finish when the whole script has terminated?0 replies 0 retweets 0 likes
@czechboy0 I guess if you want to be safer you could wait until you also get a NSTaskDidTerminateNotification.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
honza dvorsky
Michael Tsai