Skip to content

Instantly share code, notes, and snippets.

@clausd
Created September 2, 2013 19:28
Show Gist options
  • Save clausd/6416463 to your computer and use it in GitHub Desktop.
Save clausd/6416463 to your computer and use it in GitHub Desktop.
Nonblocking writes, blocking reads
`mkfifo fifotest`
Process.fork do
puts "We're going to write a message to a process who will pick it up later"
nonblocking = open('fifotest', 'w+')
nonblocking.puts "A message for you, Rudy\r\n"
nonblocking.flush
nonblocking.close
puts "Done writing"
end
puts "Going to read"
blocking = open('fifotest', 'r+')
puts blocking.readline
puts "Going to block, since nothing is there"
puts blocking.readline
blocking.close
# echo go away > fifotest
# terminates the script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment