Code samples for the post about open3 usage.

Code sample one: Debug Interrupt Simulation

If you open3 this program in a naïve way, it will work if the number is small enough (say, 100), and will deadlock if the number is large enough (say, 100000).

Code sample two: reply.rb, program echoes to random output stream

This program echoes the input linewise to either stdout or stderr, randomly.

Code sample three: complete listing of sample open3 usage

Code sample four: Perl version of open3 wrapper

This is a less feature-rich wrapper of open3. It can't handle interactiveness, and, aside from reading from standard output and error, can only write some text to child's input at the beginning of the execution (not in the middle of it, based on a response from callbacks).