Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Background process

by DeadPoet (Scribe)
on Jan 11, 2011 at 19:40 UTC ( #881739=note: print w/replies, xml ) Need Help??


in reply to Re^3: Background process
in thread Background process

Silly example, but might help.
#! 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.

--Poet

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://881739]
help
Chatterbox?
[Corion]: marto: Oh, I'm jealous. I'm going to see DM in Frankfurt, but it's a stadium full of people, so, rather a big thing where you mostly get to see the band on screens ;)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2017-03-24 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (301 votes). Check out past polls.