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 But note that you can get NSTaskDidTerminateNotification before the last NSFileHandleReadCompletionNotification…0 replies 0 retweets 0 likes -
@mjtsai Hmm. Sorry, I still can't see exactly how to quickly improve the script I have. Maybe fork the gist and show me? :)0 replies 0 retweets 0 likes
@czechboy0 No time for that at the moment, but maybe I can write a blog post sometime.
-
@mjtsai Let me know if you do. Thanks!0 replies 0 retweets 0 likes
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