Created
October 4, 2012 00:24
-
-
Save mariash/3830763 to your computer and use it in GitHub Desktop.
ruby popen fds
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
open('/tmp/f','w'){|f| f << 'sekrit'} | |
f = open('/tmp/f') | |
exec("ruby -e 'p IO.open(#{f.fileno}).read'") | |
# Prints 'sekrit' |
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
open('/tmp/f','w'){|f| f << 'sekrit'} | |
f = open('/tmp/f') | |
IO.popen("ruby -e 'p IO.open(#{f.fileno}).read'") | |
# Fails 'Bad file descriptor' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment