How can I kill ping (or another VERY LONGEST without a timeout, etc. system process) (ping is just a simple example) in ruby Thread:
a = Thread.new do
system 'ping localhost'
end
a.kill
a.exit
a.terminate
while true
sleep 5
p a.alive?
end
Output: =>
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=1 ttl=64 time=0.023 ms
....
true
64 bytes from localhost.localdomain (127.0.0.1): icmp_req=7 ttl=64 time=0.022 ms
.....
true
......
So, I need to stop the ping process with Thread, but I do not know how to do this.
source
share