Created
September 5, 2015 00:24
-
-
Save oconnor663/922b8d53a742c45e5a46 to your computer and use it in GitHub Desktop.
Why does this hang on Mac but not on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
r, w = os.pipe() | |
# Small enough to fit in the pipe buffer; won't hang. | |
os.write(w, b"one\ntwo\n") | |
# Call head twice. The first time works fine. The second hangs, but only on OSX! | |
subprocess.call(['head', '-c', '4'], stdin=r) | |
subprocess.call(['head', '-c', '4'], stdin=r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment