I’m looking for a way to forcibly terminate a process started with a
pipe. That is, when I run:
file = IO.popen(“sleep 300”, “r+”)
file.close
The file.close command just hangs and waits for the sleep command to
finish. Is there some way I can instead say, “I don’t care if it’s
finished or not, kill the program now and close the pipe”?
I’m looking for a way to forcibly terminate a process started with a
pipe. That is, when I run:
file = IO.popen(“sleep 300”, “r+”)
file.close
The file.close command just hangs and waits for the sleep command to
finish. Is there some way I can instead say, “I don’t care if it’s
finished or not, kill the program now and close the pipe”?
Thanks,
Jared
Try this:
p = IO.popen(“sleep 10”, “r+”)
id = p.pid
puts id
sleep(5)
Process.kill(“SIGALRM”, id)
The man page for sleep says:
The sleep utility exits with one of the following values:
0 On successful completion, or if the signal SIGALRM was