#! perl -slw use POSIX qw(:errno_h :sys_wait_h); use constant { RET_SUCCESS => 1, RET_FAILURE => 0, }; sub check_process_signal { my $sig = shift; if ( WIFEXITED($sig) ) { print q{process normal exit}; return RET_SUCCESS; } elsif ( WIFSIGNALED($sig) ) { print q{process terminated because of signal}; return RET_FAILURE; } elsif ( WIFSTOPPED($sig) ) { print q{process is stopped}; return RET_FAILURE; } return RET_SUCCESS; } my $pid = #run your command however.... waitpid( $pid, 0 ); if ( check_process_signal( $? ) ) { ## success... } else { ## failure ... }
Coded on the fly sorry if there are any errors.
--PoetIn reply to Re^4: Background process
by DeadPoet
in thread Background process
by tart
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |