in reply to Re: Background process using a system call
in thread Background process using a system call
You've got the parent/child comments the wrong way round, you may as well use exec instead of the system/exit pair, and why not catch all of those return codes from rsh?
local (%rc, $running); # turn off stdout buffering $| = 1; # catch return codes local $SIG{CHLD} = sub { $rc{wait()} = $?; --$running; }; foreach my $wks (@wkslist) { if ( my $pid = fork() ) { # parent ++$running; } else { # child print "rshing to $wks\n"; exec($rsh_cmd, $wks, "ls"); } } sleep while ($running);
I have an old snippet which you may find useful at Run some commands in parallel
Are you writing a program to execute arbitrary commands on multiple hosts at the same time? If so, check back in a day or two and I'll have the script I use posted that packs in a few features.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Background process using a system call
by maverick (Curate) on Aug 21, 2001 at 05:09 UTC |