Skip to content

Instantly share code, notes, and snippets.

@tansengming
Created October 7, 2009 07:50
Show Gist options
  • Save tansengming/203858 to your computer and use it in GitHub Desktop.
Save tansengming/203858 to your computer and use it in GitHub Desktop.
rd, wr = IO.pipe
if fork
wr.close
puts "Parent got: <#{rd.read}>"
rd.close
Process.wait
else
rd.close
puts "Sending message to parent"
wr.write "Hi Dad"
wr.close
end
# Produces
# Sending message to parent
# Parent got: <Hi Dad>
# From: http://www.ruby-doc.org/docs/rdoc/1.9/classes/IO.html#M001074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment