kareman / SwiftShell

A Swift framework for shell scripting.
https://kareman.github.io/SwiftShell
MIT License
1.03k stars 87 forks source link

run().read()'ing particularly long outputs causes a hang #15

Closed master-nevi closed 8 years ago

master-nevi commented 8 years ago

Basically NSTask.waitUntilExit() never returns for some reason. Easy to reproduce by calling cat <some_large_text_file>.txt

screen shot 2016-03-02 at 3 09 22 pm

kareman commented 8 years ago

Hi, judging by the screenshot it seems like you're using version 1. I get the same error in the latest version (2):

run("cat","longtext.txt")

This function does indeed call task.waitUntilExit(). This however does not and works fine:

runAsync("cat","longtext.txt").stdout.read()
kareman commented 8 years ago

Postponing task.waitUntilExit() until after reading all of the output fixed the problem. I still want to wait until the task has finished just in case it does some work after closing its standard output.

@master-nevi and thanks for reporting this. Please let me know if this fixes the problem for you.