thanks for the help, I did add additional exit codes in the my child processes and it solved my problems (I posted code below)
in the end, I figured the easiest way is for the parent to keep track of the children's exit status; because in the end that's all I care about.
I don't have access to "update" my version of perl (or add modules), but I'm definitely going to look more into the IPC, it really interests me.
foreach $element (@updevices) { @ip = split(':',$element); die "Could not fork()\n" unless defined ($pid = fork); if ($pid) { push @pids, $pid; next;} system("ping $ip[2] 2 > /dev/null"); $result = $?; if ( $result != 0) { print "$ip[0] is dead\n"; exit 1; } exit 0; } for $pid(@pids){ waitpid $pid, 0; if ($? != 0) { $i++; } } print "$i dead devices\n";
In reply to Re^4: Problem with exit status of bash script
by dizzyd719
in thread Problem with exit status of bash script
by dizzyd719
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |