in reply to PAR-Packer and IPC-Run

Hm-m, suppose:

use strict; use warnings; use IPC::Run qw( start ); my @c = qw( cmd /c sort ); my $h = start \@c, '<pipe', \*IN, '>pipe', \*OUT; print IN "zzz...\n"; print IN "hello world\n"; close IN; pump $h; print uc while <OUT>; close OUT; finish $h;

to print uppercased sorted lines:

HELLO WORLD ZZZ...

But if packed to executable:

pp -o pack_test.exe pack_test.pl

the pack_test.exe gives:

Inappropriate I/O control operation: Win32::Process::Create() at C:\Us +ers\me\AppData\Local\Temp\par-766164696d\cache-2f8c1556e4a094e1c7eee6 +ea88e299192e77e2e4\inc\lib/IPC/Run.pm line 2150. Inappropriate I/O control operation: Win32::Process::Create() at C:\Us +ers\me\AppData\Local\Temp\par-766164696d\cache-2f8c1556e4a094e1c7eee6 +ea88e299192e77e2e4\inc\lib/IPC/Run.pm line 2251.

Looks like Win32::Process::Create wants absolute path at #345, and IPC::Run::Win32IO is overly optimistic to find it in $^X. Within PAR, this variable contains just 'perl.exe'. Even if there's no such file on the system.

In fact, I don't know how to properly invoke perl from PAR bundle (it does contain all binaries, doesn't it), so here's a dirty hack. Somewhere at line #311, put

local $^X = $ENV{ PAR_TEMP } . '\inc\perl.exe' if $^X eq 'perl.exe' and exists $ENV{ PAR_TEMP };

And then pack like this:

pp -M IPC::Run::Win32Pump -a C:\berrybrew\strawberry-perl-5.32.1.1-64b +it-PDL\perl\bin\perl.exe;perl.exe -o pack_test.exe pack_test.pl

and then pack_test.exe kindly gives:

HELLO WORLD ZZZ...

I have no idea if it's IPC::Run or PAR::Packer (or Perl itself built on Windows) fault; and whether it'll work for your multi-gigabyte multi-threaded app; and how many refined professionals dropped unconscious because of ugliness of the above hack, but it's something to start with.

Replies are listed 'Best First'.
Re^2: PAR-Packer and IPC-Run
by izomiac (Novice) on Oct 12, 2023 at 05:31 UTC
    That fixed it! You've saved me many hours of work in re-implementing the IPC to avoid using that module, which also would have lost STDERR monitoring. Thank you very much.


    Edit:
    Looks like that solved the compiling problem, and works great for the isolated example, but introduced a nasty memory leak in my actual script... 115 GB used in about 30 seconds before it failed by running out of memory. I suspect that might have been what messed up Perl2Exe since it basically kept relaunching my app like I'd put a while(1) loop around my code. I'll have to investigate further, the launcher component is purposefully kept as simple as possible and just handles launching and coordination. I appreciate your help as I didn't really know where to even start to fix that problem since I had no idea how the PAR environment differed from the standard PERL environment.