From: Nate Murray Date: 2006-11-21T05:15:07+09:00 Subject: Re: fork, trap and exec. Pickaxe typo? Another question, trap("CLD") should be called even with a non-zero exit status, correct? FYI, I am running under MacOSX 10.4 $ ruby --version ruby 1.8.4 (2005-12-24) [i686-darwin8.6.1] Nate Murray wrote: > Hey All, I got this code straight from the PickAxe: > > trap("CLD") { > pid = Process.wait > puts "Child pid #{pid}: terminated" > exit > } > > > exec("echo 'hello world'") if fork == nil > > But it doesnt word! > The CLD trap'ped call never executes. > > > Another question... If I perform the exec 4 times the trap call back > should be called four times, right? > > So this code: > > trap("CLD") { > pid = Process.wait > puts "Child pid #{pid}: terminated" > exit > } > > 1.upto(4) do > exec("echo \"hello $HOSTNAME #{Process.pid}\n\" ; sleep 5") if > fork.nil? > end > > Should call trap("CLD") four times, right? > > Thanks for your help in advance.