From aba7c124e3402a39a8237a7ae0ec4bc15f4016ce Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Mon, 10 Mar 2014 17:12:26 +0100 Subject: ignore_fail for spawn_with_timeout --- lib/nlp_ruby/misc.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/nlp_ruby/misc.rb b/lib/nlp_ruby/misc.rb index b2ab885..0319a5f 100644 --- a/lib/nlp_ruby/misc.rb +++ b/lib/nlp_ruby/misc.rb @@ -58,14 +58,14 @@ class PriorityQueue end end -def spawn_with_timeout cmd, t=4, debug=false +def spawn_with_timeout cmd, t=4, ignore_fail=false, debug=false STDERR.write cmd+"\n" if debug pipe_in, pipe_out = IO.pipe pid = Process.spawn(cmd, :out => pipe_out) begin Timeout.timeout(t) { Process.wait pid } rescue Timeout::Error - Process.kill('TERM', pid) + Process.kill('TERM', pid) if !ignore_fail end pipe_out.close return pipe_in.read -- cgit v1.2.3