On Nov 30, 2007, at 11:47 PM, Joel VanderWerf wrote: > James Edward Gray II wrote: >> I'm pretty sure we have found a bug in Ruby while working on >> TextMate. >> This simple script shows the issue with recent versions of Ruby on > at least Mac OS X and FreeBSD: >> #!/usr/bin/env ruby -wKU >> trap('SIGINT') { warn "#{Time.now} receive" } >> fork { sleep 0.5 >> warn "#{Time.now} вл send" >> Process.kill('SIGINT', Process.ppid) } >> %x{true} # comment out this line to eliminate the pause >> pid = fork { exec('sleep', '4') } >> Process.wait(pid) >> When this script is run we see a four second delay between the two > times. However, you can comment out the %w{true} line and the >> script then behaves as expected (no delay). >> Using SIGUSR1 instead of SIGINT also resolves the issue. >> The script did work correctly on CentOS with Ruby 1.8.1, so either > the change of OS helped or it's a newer bug. >> James Edward Gray II > > Some observations: > > 1. system("") has the same effect as %x{true} > > 2. Having a second thread running eliminates the pause. > > 3. Reinstalling the INT handler after the system() call eliminates > the pause. > > My test code: > > trap('SIGINT') { warn "#{Time.now} receive" } > fork { sleep 0.5 > warn "#{Time.now} send" > Process.kill('SIGINT', Process.ppid) } > > #Thread.new {sleep} # comment out this line to eliminate the pause > > #trap('SIGINT') { warn "#{Time.now} receive" } > system "" # comment out this line to eliminate the pause > > # reinstalling the INT handler eliminates the pause: > #trap('SIGINT') { warn "#{Time.now} receive" } > > pid = fork { exec('sleep', '4') } > Process.wait(pid) Any thoughts on this from the core team? James Edward Gray II