open3 only takes STDIN, STDOUT and STDERR. If the command being run uses other file descriptors then open3 cannot capture those:
echo foo # Can be captured
echo foo >&2 # Can be catured
echo foo >&3 # Cannot be captured (with open3)
I have looked into IPC::Run::run which seems to be able to deal with that, but I also need the PID and I found no way for IPC::Run::run to give me that.
Is there an openN or a way for IPC::Run::run to give me the PID?
Background
This is intended for a possible extension of GNU Parallel, so you can do:
parallel 'echo {} start >&3;sleep 10;echo {} end >&3' ::: a b c 3>out.file
without having the output from different jobs mixed. GNU Parallel needs to keep track of each pid - especially when --keep-order
is used.
IPC::Run::run
byIPC::Run::start
and dump the returned object. Unfortunately this is not documented, so you're on your own... – Slaven Rezicecho {} start >&3;sleep 10;echo {} end >&3
as the command being run and fd3 assigned to a perl file handle, I will accept that as an answer. – Ole Tange