Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Use PAR::Packer - pp when use fork

10 views
Skip to first unread message

Vld SFR

unread,
Apr 25, 2020, 7:15:03 PM4/25/20
to p...@perl.org
Hello,
first thank you for creating PAR: Packer
Unfortunately when I use fork or modules using fork like POE :: Wheel :: run or Parallel :: ForkManager the script ends before the fork son hands over.
If below an example
Version perl : perl 5, version 28, subversion 2 (v5.28.2) built for 
MSWin32-x86-multi-thread-64int
Windows 10 64Bits
Script test :
use strict;
    use warnings;
    use diagnostics;
    use 5.010;

    my $name = 'Foo';

    say "PID $$";
    my $pid = fork();
    die if not defined $pid;
    if (not $pid) {
       say "In child  ($name) - PID $$ ($pid)";
       $name = 'Qux';
        sleep 2;
       say "In child  ($name) - PID $$ ($pid)";
       exit;
    }

    say "In parent ($name) - PID $$ ($pid)";
    $name = 'Bar';
     sleep 2;
    say "In parent ($name) - PID $$ ($pid)";

    my $finished = wait();
    say "In parent ($name) - PID $$ finished $finished";
display
PID 9400
    In parent (Foo) - PID 9400 (-9928)
    In child  (Foo) - PID -9928 (0)
    In parent (Bar) - PID 9400 (-9928)
    In child  (Qux) - PID -9928 (0)
    In parent (Bar) - PID 9400 finished -9928
    pack : pp -c -x fork.pl -o fork.exe

    Display:

    PID 8384
    In parent (Foo) - PID 8384 (-4572)
    In child  (Foo) - PID -4572 (0)
    In parent (Bar) - PID 8384 (-4572)
    In child  (Qux) - PID -4572 (0)

The finished script without waiting for the children
how to use pp with scripts using fork
0 new messages