in reply to Script hangs when called via IPC::Open3

I'm not sure what's going on here exactly, but check this out from the fine documentation for IPC::Open3:

If you try to read from the child’s stdout writer and their stderr writer, you’ll have problems with blocking, which means you’ll want to use select() or the IO::Select, which means you’d best use sysread() instead of readline() for normal stuff.

Sounds right to me. Why not try it?

UPDATE: Oh, now I see it. It's the wait(). You're trying to let the process finish but it can't finish because it has filled it's STDOUT buffer and can't continue. It works with small numbers because the buffer doesn't fill. Remove that wait() and your code runs to completion.

UPDATE 2: For what it's worth, Expect is, in my experience, a better tool for this type of job. The documentation is a total mess but if you've ever used the TCL Expect it works the same way. Unlike IPC::Open3, it takes care of all the messy buffering and deadlocking problems. All you have to do is write the matching code.

-sam

  • Comment on Re: Script hangs when called via IPC::Open3