From: Bertram Scharpf Date: 2007-10-04T19:08:38+09:00 Subject: Re: Signal handling strangeness (Linux) Hi, Am Donnerstag, 04. Okt 2007, 18:47:25 +0900 schrieb Han Holl: > #!/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 [...] be terminated with 'kill -TERM pid'. > It hangs on a waitpid (or wait4) for the tail process. > Why is this ? And is it reasonable ? The wait is part of popen. So, `tail' runs until Process.pid(==$$) terminates and $$ waits for the `tail' to finish. It's a deadlock but it's the correct behaviour. You should state a clear definition which task is to be stopped. You can offer a pid or a kill command by another feature of your Ruby application. I did a lot process and thread scheduling and at least to me it comes hard every time anew. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de