H
Han Holl
Hi,
The following program:
#!/usr/bin/ruby -w
IO.popen("tail -F --lines=0 --pid=#{Process.pid} /var/log/messages") do |h|
while line = h.gets
puts line
end
end
# end-of-program
can be terminated with 'kill -TERM pid'.
This one:
#!/usr/bin/ruby -w
trap('TERM') do
exit
end
IO.popen("tail -F --lines=0 --pid=#{Process.pid} /var/log/messages") do |h|
while line = h.gets
puts line
end
end
# end-of-program
cannot. It hangs on a waitpid (or wait4) for the tail process.
Why is this ? And is it reasonable ?
Han Holl
PS Forgot to say: this is Linux.
The following program:
#!/usr/bin/ruby -w
IO.popen("tail -F --lines=0 --pid=#{Process.pid} /var/log/messages") do |h|
while line = h.gets
puts line
end
end
# end-of-program
can be terminated with 'kill -TERM pid'.
This one:
#!/usr/bin/ruby -w
trap('TERM') do
exit
end
IO.popen("tail -F --lines=0 --pid=#{Process.pid} /var/log/messages") do |h|
while line = h.gets
puts line
end
end
# end-of-program
cannot. It hangs on a waitpid (or wait4) for the tail process.
Why is this ? And is it reasonable ?
Han Holl
PS Forgot to say: this is Linux.