From: Denis Berezhnoy Date: 2009-09-11T09:56:15+09:00 Subject: Re: Can not catch PTY::ChildExited exception Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Can not catch PTY::ChildExited exception" > on Wed, 9 Sep 2009 15:14:09 +0900, Denis Berezhnoy > writes: > > |I have problem that I can not catch PTY::ChildExited exception. Here is > |the code: > > The exception was raised when the child process terminated > (asynchronously), so you need to wrap not only spawn but everything. > > matz. Hello Matsumoto-san, Thank you very much for clarifications! I tried to wrap around whole code with begin rescue block and I can catch ChildExited exception. So now I have code like this: require 'pty' cmd = "/home3/cman/work/product/integrator/test/syb2/OCS-15_0/bin/isql -Uuser2 -Puser2 -Scman2" begin pipe_read, pipe_write, pid = PTY.spawn(cmd) sleep 10 printf "TEST END\n" rescue PTY::ChildExited => msg puts "Caught child exited exception!" rescue => msg puts "Caught exception!" rescue => e puts e.msg puts e.type end But now the problem is that ChildExited exception can occur at any moment after spawn and interrupt program in random place. In my test above I never get TEST END printed. How can I handle this in right way? Best regards, Denis -- Posted via http://www.ruby-forum.com/.