X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=lib%2Fmcollective%2Fvendor%2Fsystemu%2Fsamples%2Ff.rb;fp=lib%2Fmcollective%2Fvendor%2Fsystemu%2Fsamples%2Ff.rb;h=158301de88c125ce7189e68a8f40f7d9b79a7207;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/lib/mcollective/vendor/systemu/samples/f.rb b/lib/mcollective/vendor/systemu/samples/f.rb new file mode 100644 index 0000000..158301d --- /dev/null +++ b/lib/mcollective/vendor/systemu/samples/f.rb @@ -0,0 +1,18 @@ +# +# if a block is specified then it is passed the child pid and run in a +# background thread. note that this thread will __not__ be blocked during the +# execution of the command so it may do useful work such as killing the child +# if execution time passes a certain threshold +# + require 'systemu' + + looper = %q( ruby -e" loop{ STDERR.puts Time.now.to_i; sleep 1 } " ) + + status, stdout, stderr = + systemu looper do |cid| + sleep 3 + Process.kill 9, cid + end + + p status + p stderr