Project

General

Profile

Actions

Bug #8708

closed

It seems that a call to the "system" changes the handler of the INT signal

Added by bdimych (Dmitry Bolshakov) over 11 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p429 (2013-05-15) [i386-cygwin]
Backport:
[ruby-core:56271]

Description

this is only on cygwin, on linux all ok
$ uname -a
CYGWIN_NT-5.1 bolshakovxp 1.7.21(0.267/5/3) 2013-07-15 12:17 i686 Cygwin

--- test script ---

#!/usr/bin/ruby
STDOUT.sync = true
puts 'before "system" ctrl-c stops the script immediately'
STDIN.sysread(1)

intTrap = trap 'INT', 'DEFAULT' # ---------------------- if uncomment this wrapper

system 'echo blabla'

trap 'INT', intTrap # ---------------------------------- then ctrl-c works immediately

puts 'but after "system" ctrl-c waits until I press Enter'
STDIN.sysread(1)

--- output ---

$ ./x.rb
before "system" ctrl-c stops the script immediately
./x.rb: Interrupt

$ ./x.rb
before "system" ctrl-c stops the script immediately

blabla
but after "system" ctrl-c waits until I press Enter
I'm pressing ctrl-c right now... but it stops only after Enter
./x.rb: Interrupt

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

  • Status changed from Open to Feedback
  • Backport deleted (1.9.3: UNKNOWN, 2.0.0: UNKNOWN)

Can you reproduce this issue with a currently supported Ruby version and current version of Cygwin? I tried the script on OpenBSD and on Windows and it works fine in both cases.

Updated by duerst (Martin Dürst) over 5 years ago

  • Status changed from Feedback to Closed

I'm using a cygwin version with a date from this year:

$ uname -srv
CYGWIN_NT-6.3 3.0.7(0.338/5/3) 2019-04-30 18:08

I'm not 100% sure I'm doing the right thing, but I get the following:

$ ruby issue8708x.txt
before "system" ctrl-c stops the script immediately
Traceback (most recent call last):
        1: from issue8708x.txt:4:in `<main>'
issue8708x.txt:4:in `sysread': Interrupt


$ ruby issue8708x.txt
before "system" ctrl-c stops the script immediately

blabla
but after "system" ctrl-c waits until I press Enter
Traceback (most recent call last):
        1: from issue8708x.txt:9:in `<main>'
issue8708x.txt:9:in `sysread': Interrupt

In the first case, my input is "Ctrl-C", in the second case, it's "Enter", then "Ctrl-C", but without an additional "Enter". So the issue seems to be resolved. Closing.

Actions

Also available in: Atom PDF

Like0
Like0Like0