From: Paul Brannan Date: 2007-10-10T22:10:54+09:00 Subject: Re: Signal handling strangeness (Linux) On Sat, Oct 06, 2007 at 05:45:19AM +0900, Han Holl wrote: > so it would seem that 'waitpid() is closely related to the atexit() functions. It doesn't have anything to do with atexit except that the atexit handlers and finalizers are both run when an application terminates normally. The finalizer also gets run if the object gets finalized, so not closing the handle before all references to the object go away can also cause problems. > The following would be nice to have: > trap('TERM') do > kill child_process > end > This woulr let me do at_exit processing as well. > But I haven't found out how to get the pid of the child with IO.popen. You can't. (That's not 100% true -- I once implemented something like this in ruby that passed a dummy flag to the child and used pgrep to find the child's pid, but you probably don't want to go that route; it's easier to fork/exec yourself or use popen4). Paul