158301de88c125ce7189e68a8f40f7d9b79a7207
[packages/precise/mcollective.git] / lib / mcollective / vendor / systemu / samples / f.rb
1 #
2 # if a block is specified then it is passed the child pid and run in a
3 # background thread.  note that this thread will __not__ be blocked during the
4 # execution of the command so it may do useful work such as killing the child
5 # if execution time passes a certain threshold
6 #
7   require 'systemu'
8
9   looper = %q( ruby -e" loop{ STDERR.puts Time.now.to_i; sleep 1 } " )
10
11   status, stdout, stderr =
12     systemu looper do |cid|
13       sleep 3
14       Process.kill 9, cid
15     end
16
17   p status
18   p stderr