Skip to content

Instantly share code, notes, and snippets.

@oconnor663
Created September 5, 2015 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oconnor663/922b8d53a742c45e5a46 to your computer and use it in GitHub Desktop.
Save oconnor663/922b8d53a742c45e5a46 to your computer and use it in GitHub Desktop.
Why does this hang on Mac but not on Linux
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