Skip to content

Commit

Permalink
Specs: fix CHLD signal handler spec that had a race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Feb 10, 2019
1 parent d956786 commit c606ab5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions spec/std/signal_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,16 @@ describe "Signal" do
end

it "CHLD.trap is called after default Crystal child handler" do
called = false
child = nil
chan = Channel(Process).new

Signal::CHLD.trap do
called = true
Process.exists?(child.not_nil!.pid).should be_false
child_process = chan.receive
Process.exists?(child_process.pid).should be_false
end

child = Process.new("true", shell: true)
child.not_nil!.wait # doesn't block forever
called.should be_true
child.wait
chan.send(child)
end

# TODO: test Signal::X.reset
Expand Down

0 comments on commit c606ab5

Please sign in to comment.