我有一个超时运行的外部脚本。
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
但是,如果超时超时,则需要终止外部脚本。我怎么能杀了它?