From: Brian Candler Date: 2005-07-06T18:27:25+09:00 Subject: Re: Exececuting another application from within ruby On Tue, Jul 05, 2005 at 06:20:38PM +0900, nobuyoshi nakada wrote: > > 'atexit' script you've previously defined will run in both parent and child. > > No, system nor exec don't invoke at_exit handlers. > > $ ruby -e 'at_exit{puts "#$$ exiting"}; system("echo foo")' > foo > 1020 exiting It's clear that if the exec succeeds then no at_exit handler can possibly be called; more interesting is the case if it fails. It looks like the at_exit handler is not called there - I hadn't tested it before. $ ruby -e 'at_exit{puts "#$$ exiting"}; system("zxcvzxcv"); p $?' # 31774 exiting $ However: $ ruby -e 'at_exit{puts "#$$ exiting"}; Process.waitpid(fork {exec("zxcvzxcv")}); p $?' 44096 exiting -e:1:in `exec': No such file or directory - zxcvzxcv (Errno::ENOENT) from -e:1 from -e:1:in `fork' from -e:1 # 44095 exiting which is what I was expecting. Anyway, it's a useful mental note to keep :-) Cheers, Brian.