Skip Menu |

This queue is for tickets about the IPC-Cmd CPAN distribution.

Report information
The Basics
Id: 88063
Status: new
Priority: 0/
Queue: IPC-Cmd

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.84
Fixed in: (no value)



Subject: IPC::Cmd could use Win32::Job
That primary problem people seem to have trying to do that fork , redirect, exec idiom, which doesn't work on win32 where forks == threads, is reasonably straight forward to do with Win32::Job

It wraps the internal win32 create process command so that you can specify arbitrary input and ouput handles as parameters, and IPC::Cmd could try using this if it was present ( and recommend via runtime.recommends )

use Win32::Job;

my $process = Win32::Job->new();
$process->spawn("$binarypath", "@ARGS" , {
    stdin => $handle,
    stdout => $other_handle,
    stderr => $other_err_handle
});
$process->run(-1);

run() blocks until the process terminates, so you still want to do this in a fork() with a cleanup on the child when the fork exits.

I have a working example implementation of something that would be easier to implement in IPC::Cmd if it had Win32 Fork support, using Win32::Job

https://metacpan.org/source/KENTNL/IPC-Run-Fused-0.04000100/lib/IPC/Run/Fused/Win32.pm