On Tue, 21 Nov 2006, Nate Murray wrote:

> Hey All, I got this code straight from the PickAxe:
> 
> 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

  sleep 25
> 
> Should call trap("CLD") four times, right?
> 
> Thanks for your help in advance.

that should do the job.  You didn't wait around for things to happen.
        Hugh
> 
> 
>