Skip to content

Rubinius terminates actions on SIGINT, regardless of signal handler #2093

Closed
Quintus opened this Issue Dec 9, 2012 · 0 comments

2 participants

@Quintus
Quintus commented Dec 9, 2012

Hi there,

Rubinius shows a strange behaviour when registering a signal handler via #trap. In the following code:

trap "SIGINT" do
  puts "Cought SIGINT!"
end

sleep 10
puts "After sleep"

Rubinius will terminate the #sleep immediately when it receives a Ctrl-C. In the following demo run I pressed Ctrl-C after about two seconds:

% ruby foo.rb    
^CCought SIGINT!
After sleep

MRI shows the expected behaviour of letting #sleep continue:

(1026) [21:24:19 quintus@hades] /tmp
% use mri
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
(1027) [21:25:36 quintus@hades] /tmp
% ruby foo.rb 
^CCought SIGINT!
^CCought SIGINT!
^CCought SIGINT!
After sleep

The behaviour is similar with Thread joins:

trap "SIGINT" do
  puts "Cought SIGINT!"
end

t = Thread.new{sleep}
t.join(10)

puts "After sleep"

Probably the behaviour is similar with non-sleeping expressions, but I can’t think of an atomic long-running expression at the moment to test it...

Rubinius version is from today’s master: rubinius 2.0.0rc1 (1.9.3 146bdc00 2012-11-02 JI) [x86_64-unknown-linux-gnu]

OS is Arch Linux 64 bits.

Valete,
Marvin

@dbussink dbussink added a commit that closed this issue Feb 5, 2013
@dbussink dbussink Handle signals after pthread_cond_wait is interrupted
There might be signals that need to be run if pthread_cond_wait is
interrupted. Fixes #2093
761cafc
@dbussink dbussink closed this in 761cafc Feb 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.