I already have a solution using extprog
that mostly works, the problem with that approach is that, as sshg3
reuses the connections, you never kwnow if it is actually going to run the helper program or not and when it doesn't, the parent just get stalled at the $pipe->Connect
The option I am considering now is opening an anonymous pipe on the parent (just using pipe), mark the read side as inheritable and then recover and use it from the helper. The problem is reconstructing a Perl level fh from the windows handler... probably, the easiest solution would be to move away from Perl there, program the helper in C and just bundle it precompiled.
Anyway, I still have to check that the file handle survives the full chain of program calls (perl -> sshg3 -> cmd -> helper).
Also, a minor issue I have found with extprog is that a console window pops up briefly. Besides the visual ugliness what really worries me is if that could cause the helper invocation to fail on contexts lacking a GUI environment. For instance, when called from the task scheduler, a web server, or any other program not started inside an user session.