From: akr@... Date: 2014-05-05T17:05:11+00:00 Subject: [ruby-core:62397] [ruby-trunk - Bug #5487] [Rejected] popen3 + timeout regression in ruby 1.9 Issue #5487 has been updated by Akira Tanaka. Status changed from Assigned to Rejected Please avoid Timeout. Even if it doesn't hang as Ruby 1.8, it doesn't clean child processes. Thread#join's argument (timeout) is usable to implement to timeout. ``` Open3.popen3("sleep 100 && echo hi", :pgroup=>true) {|i, o, e, w| th = Thread.new { e.read } if !w.join(1) # wait thread does not end within 1 second? Process.kill(:TERM, -w.pid) # kill the process group end p th.value } ``` ---------------------------------------- Bug #5487: popen3 + timeout regression in ruby 1.9 https://bugs.ruby-lang.org/issues/5487#change-46554 * Author: William Morgan * Status: Rejected * Priority: Normal * Assignee: Akira Tanaka * Category: core * Target version: * ruby -v: 1.9.2p290 * Backport: ---------------------------------------- Wrapping Open3.popen3 in a Timeout::timeout block used to work in Ruby 1.8, but doesn't work in 1.9: w@masanjin:~$ cat timeout.rb require 'timeout' require 'open3' Timeout::timeout(1) { Open3.popen3("sleep 100 && echo hi") { |i, o, e| e.read } } w@masanjin:~$ /usr/bin/ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux] w@masanjin:~$ /usr/bin/ruby timeout.rb /usr/lib/ruby/1.8/timeout.rb:60: execution expired (Timeout::Error) from /usr/lib/ruby/1.8/open3.rb:86:in `popen3' from timeout.rb:4 from timeout.rb:4 w@masanjin:~$ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] w@masanjin:~$ ruby timeout.rb [sleeps forever] -- https://bugs.ruby-lang.org/