File: f.rb

package info (click to toggle)
ruby-systemu 2.6.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 164 kB
  • sloc: ruby: 525; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 498 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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