Skip to content

Instantly share code, notes, and snippets.

@franckverrot
Last active August 29, 2015 14:27
Show Gist options
  • Save franckverrot/bc34b588580cff836c87 to your computer and use it in GitHub Desktop.
Save franckverrot/bc34b588580cff836c87 to your computer and use it in GitHub Desktop.
Python vs Ruby on a closed stdout
##### Python
λ (echo 'before'; exec 1>&-; python -c 'print("after")')
before
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
### Ruby
λ (echo 'before'; exec 1>&-; ruby -e 'puts("after")')
before
λ (echo 'before'; exec 1>&-; ruby -e 'puts("1"*8190)'); # Sending 8191 chars
before
λ (echo 'before'; exec 1>&-; ruby -e 'puts("1"*8191)'); # Sending 8192 chars
before
-e:1:in `write': Broken pipe @ io_write - <STDOUT> (Errno::EPIPE)
from -e:1:in `puts'
from -e:1:in `puts'
from -e:1:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment