I try to unlock the subprocess, waiting for it to complete, if it does not end in a certain time, kill it.
This is what I have so far:
servers.each do |server| pid = fork do puts "Forking #{server}." output = "doing stuff here" puts output end Process.wait puts "#{server} child exited, pid = #{pid}" end
Somewhere after / around Process.wait, I would like some utility to wait 20 seconds, and if the process is still there, I would kill it and mark the output as "ERROR".
I am new to fork / exec. My code actually works, but I just don't know how to approach the waiting / killing aspect.
awojo source share