Updated mcollective.init according to OSCI-658
[packages/precise/mcollective.git] / lib / mcollective / vendor / systemu / samples / f.rb
diff --git a/lib/mcollective/vendor/systemu/samples/f.rb b/lib/mcollective/vendor/systemu/samples/f.rb
new file mode 100644 (file)
index 0000000..158301d
--- /dev/null
@@ -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