Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6202577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:45:38+00:00 2026-05-24T04:45:38+00:00

use strict; use warnings; use Parallel::ForkManager; my $log = /scripts/downloads/test.log; print Check the $log

  • 0
use strict;
use warnings;
use Parallel::ForkManager;

my $log = "/scripts/downloads/test.log";
  print "Check the $log file\n" and open(LOG,">$log");
   *STDERR = *LOG;
  *STDOUT = *LOG;

my $pmm=new Parallel::ForkManager(9);

my @arr=(1..200);
for(@arr){

$pmm->start and next; # do the fork
print $_."\n";
$pmm->finish; # do the exit in the child process
}

$pmm->wait_all_children;

open(READ,"$log") or die $!;
my @check=<READ>;

print "there are ".scalar @arr ." items....";
print "but we only got ".scalar @check." items\n";

This is a simplified version of a script I have going.
In this case, everytime I use more than 9 children I lose anywhere from 3-15 children, sometimes more. The obvious answer is to use less children but in my “real” script if I use less children the script will take many more hours to complete…time we don’t have. Why is it losing children and is there a way to “capture” them and re-run them if they don’t get run?

thx!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:45:39+00:00Added an answer on May 24, 2026 at 4:45 am

    You’re having all of your children write to the same logfile, and you haven’t taken any steps to prevent them from overwriting each others’ output. Without being able to reproduce the problem on my machine I can’t say for sure, but I would guess that all N children are actually running, but some of the output is getting clobbered.

    To have N processes write to the same file simultaneously without any output getting lost, you have to open the file for append rather than regular write. In C, you would use flags O_WRONLY|O_APPEND with open(2), or mode "a" with fopen(3). The kernel then ensures that all writes go to the very end of the file. (According to the man page, though, this is not reliable over NFS.) You also have to pay attention to how much you write to the file at once, or output from one process might show up in the middle of output from another. I don’t know if either of these things are possible in Perl, but it sounds like you found another solution anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!usr/bin/perl use strict; use warnings; my $file_name = rem.txt; open(FILE, $file_name); while (<FILE>) {
$ cat test.pl use strict; use warnings; sub route { print hello, world!; }
use warnings; use Test::More; use File::Find::Rule; use Test::File::Find::Rule; my $rule = File::Find::Rule->file->name('*.pl')->not_grep(qr/^\s*use\s+strict;/m, sub {
use strict; use warnings; open(FILE1, /cygdrive/c/cpros/mola.txt); my $line = <FILE1>; print $line; close(FILE1); open(FILE1,
use strict; use warnings; open(FILE1,/cygdrive/c/cpros/karthik/molk.txt); my $line = < FILE1 > ; print $line
#!/usr/bin/perl use strict; use warnings; sub paragraph { open my $file, <, dict.txt or
#!/usr/bin/perl use strict; use warnings; open(TEST, leet.txt) or die Can't open leet.txt: $!\n; while(my
I'm puzzled with this test script: #!perl use strict; use warnings; use encoding 'utf8';
#!/usr/bin/perl use strict; use warnings; open(my $vmstat, /usr/bin/vmstat 1 2>&1 |); open(my $foo, >,
Here's the code I have: use strict; use warnings; use Log::Log4perl qw(:easy); Log::Log4perl->init({ level

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.