Skip to content

Commit

Permalink
Use Process.spawn instead of fork
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-stripe committed Mar 25, 2017
1 parent 0b816ce commit ca870e3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spec/nio/selector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@
it "works with signals on the main thread" do
1000.times do
begin
pid = fork do
pid = Process.spawn('ruby', '-e', <<-'EOF'
require 'nio'
begin
r, _w = IO.pipe
selector = NIO::Selector.new
Expand All @@ -204,9 +205,10 @@
raise if ["TERM", "INT"].none? {|sig| Signal.list[sig] == e.signo}
$stderr.write("#{Process.pid}: rescued #{e}\n")
end
end
EOF
)

sleep(0.1)
sleep(1)
ensure
$stderr.write("sending term\n")
Process.kill(:TERM, pid)
Expand Down

0 comments on commit ca870e3

Please # to comment.