diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dtas.rb | 1 | ||||
-rw-r--r-- | lib/dtas/partstats.rb | 8 | ||||
-rw-r--r-- | lib/dtas/process.rb | 15 | ||||
-rw-r--r-- | lib/dtas/spawn_fix.rb | 8 |
4 files changed, 14 insertions, 18 deletions
diff --git a/lib/dtas.rb b/lib/dtas.rb index a711150..e2318c6 100644 --- a/lib/dtas.rb +++ b/lib/dtas.rb @@ -4,3 +4,4 @@ module DTAS # :nodoc: end require_relative 'dtas/compat_onenine' +require_relative 'dtas/spawn_fix' diff --git a/lib/dtas/partstats.rb b/lib/dtas/partstats.rb index 6c714b3..546b88b 100644 --- a/lib/dtas/partstats.rb +++ b/lib/dtas/partstats.rb @@ -10,6 +10,7 @@ require_relative 'sigevent' class DTAS::PartStats CMD = 'sox "$INFILE" -n $TRIMFX $SOXFX stats $STATSOPTS' include DTAS::Process + include DTAS::SpawnFix attr_reader :key_idx attr_reader :key_width @@ -56,12 +57,7 @@ class DTAS::PartStats env["INFILE"] = @infile env["TRIMFX"] = "trim #{trim_part.tbeg}s #{trim_part.tlen}s" opts = { pgroup: true, close_others: true, err: wr } - pid = begin - Process.spawn(env, CMD, opts) - rescue Errno::EINTR - # workaround for older Rubies https://bugs.ruby-lang.org/issues/8770 - retry - end + pid = spawn(env, CMD, opts) wr.close [ pid, rd ] end diff --git a/lib/dtas/process.rb b/lib/dtas/process.rb index c0ce9a3..56e88e8 100644 --- a/lib/dtas/process.rb +++ b/lib/dtas/process.rb @@ -7,6 +7,7 @@ require_relative 'xs' module DTAS::Process # :nodoc: PIDS = {} include DTAS::XS + include DTAS::SpawnFix def self.reaper begin @@ -47,12 +48,7 @@ module DTAS::Process # :nodoc: opts = { close_others: true, pgroup: true }.merge!(opts) env = env_expand(env, opts) - pid = begin - Process.spawn(env, cmd, opts) - rescue Errno::EINTR - # workaround for older Rubies https://bugs.ruby-lang.org/issues/8770 - retry - end + pid = spawn(env, cmd, opts) warn [ :spawn, pid, cmd ].inspect if $DEBUG @spawn_at = Time.now.to_f PIDS[pid] = self @@ -76,12 +72,7 @@ module DTAS::Process # :nodoc: opts[:err] = we end env = env_expand(env, opts) - pid = begin - Process.spawn(env, *cmd, opts) - rescue Errno::EINTR - # workaround for older Rubies https://bugs.ruby-lang.org/issues/8770 - retry - end + pid = spawn(env, *cmd, opts) w.close if err_str we.close diff --git a/lib/dtas/spawn_fix.rb b/lib/dtas/spawn_fix.rb new file mode 100644 index 0000000..dfcc884 --- /dev/null +++ b/lib/dtas/spawn_fix.rb @@ -0,0 +1,8 @@ +module DTAS::SpawnFix # :nodoc: + # workaround for older Rubies: https://bugs.ruby-lang.org/issues/8770 + def spawn(*args) + super(*args) + rescue Errno::EINTR + retry + end if RUBY_VERSION.to_f <= 2.1 +end |