From: Bertram Scharpf Date: 2007-10-04T21:01:47+09:00 Subject: Re: Signal handling strangeness (Linux) Hi, Am Donnerstag, 04. Okt 2007, 19:14:51 +0900 schrieb Han Holl: > On 10/4/07, Bertram Scharpf wrote: > > > 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. > > > Yes, but the deadlock isn't there without the trap('TERM'). I didn't examine it thoroughly but "exit" seems to raise an exception "SystemExit". This exception will probably not be raised before the wait statement finishes. The default signal handler for 'TERM' will not raise anything but rather try to stop the whole Ruby process. You can catch the SystemExit exception by putting a begin-rescue-end frame around your popen call. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de