-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Environment
Provide at least:
- JRuby version:
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [darwin-x86_64] - Operating system and platform (e.g.
uname -a):Darwin MB-ADPENTELA.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
Other relevant info you may wish to add: - Installed or activated gems
- Application/framework version (e.g. Rails, Sinatra)
- Environment variables
Expected Behavior
- The
Signal.trapandat_exithooks are executed in different threads leading to a race-condition where bothat_exitandSignal.trapare defined.
Example: Puma traps SIGINT and sucker_punch uses the at_exit hook leading to a SystemExit before sucker_punch workers are shutdown.
puma/puma#1675
brandonhilkert/sucker_punch#223
Actual Behavior
MRI is using the same thread for both at_exit and Signal.trap. It would be nice if there is some synchronization.
### test.rb
at_exit do
sleep(1)
puts "Thread in at_exit: #{Thread.current}"
end
Signal.trap("SIGINT") do
puts "Thread in trap: #{Thread.current}"
exit
end
sleep
## JRuby
$ RUBYOPT=-d jruby test_in_jruby.rb
Exception `Gem::MissingSpecError' at /Users/adpentela/.rvm/rubies/jruby-9.2.0.0/lib/ruby/stdlib/rubygems/dependency.rb:310 - Gem::MissingSpecError
^CThread in trap: #<Thread:0x19b33233>
Exception `SystemExit' at org/jruby/RubyKernel.java:735 - exit
Thread in at_exit: #<Thread:0x37d31475>
## MRI
$ ruby test_in_jruby.rb
^CThread in trap: #<Thread:0x00007fd94d085c40 run>
Thread in at_exit: #<Thread:0x00007fd94d085c40 run>
Let me know if I'm doing something wrong or if this is a duplicate issue.
I had a quick glance at #4956 but not sure if this is related.
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels