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 ae5d148
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions spec/std/signal_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ 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
chan.send(child)
end

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

0 comments on commit ae5d148

Please sign in to comment.