I want to create a simple IO object that represents a pipe opened to another program to that I can periodically write to another program's STDIN as my app runs. I want it to be bullet-proof (in that it catches all errors) and cross-platform. The best options I can find are:
sub io_read { local $SIG{__WARN__} = sub { }; # Silence warning. open my $pipe, '|-', @_ or die "Cannot exec $_[0]: $!\n"; return $pipe; }
Advantages:
Disadvantages
sub io_read { IO::Pipe->reader(@_); }
Advantages:
Disadvantages
There is no interface for writing to a file handle in IPC::Run, only appending to a scalar. This seems…weird.
No file handle interface here, either. I could use a code reference, which would be called repeatedly to spool to the child, but looking at the source code, it appears that it actually writes to a temporary file, and then opens it and spools its contents to the pipe'd command's STDIN. Wha?
Still no file handle interface.
What am I missing here? It seems as if this should be a solved problem, and I'm kind of stunned that it's not. IO::Pipe comes closest to what I want, but the lack of $SIG{PIPE} error handling and the lack of support for Windows is distressing. Where is the piping module that will JDWIM?
In reply to What is the preferred cross-platform IPC module? by Theory
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |