All -- I know there are some similar posts, but I am not sure if I need to re-engineer my code. I have a forking queue that will spawn a child backup process, and log everything to a file. The only problem is that I am loosing stderr. Is there an easy way to do this without reworking my code:
sub fork_backup { my $lpar = shift; if ( ( scalar keys %children ) < $max_children ) { my $pid = (open($lpar,"-|")); if ( $pid ) { # this is parent process $children{$pid} = $lpar; print "Child Backup [$pid][".$children{$pid}."] started a +t ".localtime()."\n"; print MAINLOG "\nChild Backup [$pid][".$children{$pid}."] + started at ".localtime( )."\n"; $processing_time{$pid} = time(); open(HOSTLOG,">>./$main_log_dir/$lpar.out"); print HOSTLOG "\nChild Backup [$pid][".$children{$pid}."] + started at ".localtime( )."\n"; close(HOSTLOG); } else { if ( not defined $pid ) { die "\n\nWoah: Failed to fork a child!\n"; } # this is child process # This is where the meat goes! my $backup_command; if ( ($lpar_oslevel{$lpar}) eq "5.3" || ($lpar_oslevel{$lp +ar}) eq "6.1" ) { $sysbackcmd="blah"; print "Sysback Com +mand - 5.3: $sysbackcmd\n"; #Put the real sysback command in here later (for 5.3) exec("ssh -q -o ConnectTimeOut=5 $lpar \"$sysbackcmd\" +"); #Put the real sysback command in here later (for 5.3) } else { $sysbackcmd="blah"; print "Sysback Comm +and: $sysbackcmd\n"; exec("ssh -q -o ConnectTimeOut=5 $lpar \"$sysbackcmd\" +"); } # exit child process exit 0; } } else { # too much child labor! queue for later under complete_backu +p unshift(@queue,$lpar); }

In reply to Forking Queue with Pipe (grabbing stderr) by smithgw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.