Skip to content

Instantly share code, notes, and snippets.

@simsicon simsicon/fork_env.rb

Created Sep 22, 2013
Embed
What would you like to do?
ENV will inherit content from parent, not disturbed by siblings.
ENV['p_name'] = 'master'
puts "[master] pid: #{Process.pid} pname: #{ENV['p_name']}"
p1 = Process.fork{
puts "[p1] pid: #{Process.pid} pname: #{ENV['p_name']}"
ENV['p_name'] = 'p1'
puts "[p1] pid: #{Process.pid} pname: #{ENV['p_name']}"
}
p2 = Process.fork{
puts "[p2] pid: #{Process.pid} pname: #{ENV['p_name']}"
ENV['p_name'] = 'p2'
puts "[p2] pid: #{Process.pid} pname: #{ENV['p_name']}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.