Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get the child process id in Parallel::ForkManager?
    primarykey
    data
    text
    <pre><code> use LWP::Simple; use Parallel::ForkManager; @links=( ["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe","SweetHome3D-2.1-windows.exe"], ["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg","SweetHome3D-2.1-macosx.dmg"], ["http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip","SweetHome3DViewer-2.1.zip"], ); # Max 30 processes for parallel download my $pm = new Parallel::ForkManager(30); foreach my $linkarray (@links) { my $pid = $pm-&gt;start and next; # do the fork my ($link,$fn) = @$linkarray; warn "Cannot get $fn from $link" if getstore($link,$fn) != RC_OK; print "$pid = $link is done "; $pm-&gt;finish; # do the exit in the child process } $pm-&gt;wait_all_children; </code></pre> <p>after this execution i am going pid is zero </p> <pre> 0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip is done 0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg is done 0 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe is done </pre> <p>But now I really thinking whether its really doing the fork. Why I am getting all times 0 as pid in Parallel::ForkManager? </p> <p><strong><em>EDIT 2</em></strong></p> <p>i have 2 changes </p> <pre><code>my $pid = $pm-&gt;start ; # do the fork </code></pre> <p>and <code>$$</code> for process id </p> <pre> 21892 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe is done 21893 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe is done 21892 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg is done 23120 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg is done 21892 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip is done 23146 = http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip is done </pre> <p>But now I am getting 2 twice. Why I am getting this? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload