blob: f5c1e7e97636020a9bec6c2c607712cc65bbf7ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/usr/bin/env ruby
require 'timeout'
puts 'starting process'
pid = Process.spawn('sleep 20')
begin
Timeout.timeout(5) do
puts 'waiting for the process to end'
Process.wait(pid)
puts 'process finished in time'
end
rescue Timeout::Error
puts 'process not finished in time, killing it'
Process.kill('TERM', pid)
end
|