I have an external script running in a timeout.
def perform(command)
PTY.spawn(command) do |stdout_stderr, stdin, pid|
begin
do_stuff
rescue Errno::EIO # always thrown when process completes
do_more_stuff
ensure
Process.waitpid2(pid)
end
end
end
begin
Timeout.timeout do
perform('command_that_may_run_indefinitely')
end
rescue Timeout::Error
terminate_script_here
end
However, if the timeout times out, it needs to terminate the external script. How can I kill it?