Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Check for "No child processes" internationally

by davido (Cardinal)
on May 09, 2013 at 06:45 UTC ( [id://1032728]=note: print w/replies, xml ) Need Help??


in reply to Check for "No child processes" internationally

I don't think that "No child process" is locale sensitive, but on some platforms could produce "No children" instead (citation). However, you can ignore the error message's text by remembering that $! is a dual-valued variable; In string context it returns the error message. In numeric context, it returns the error number, which can be tested against the &Errno::ECHILD constant (Errno).

Or you can use %! in some variant on the example code shown in Errno's POD:

# A variation on Errno's POD example: use Errno qw( ECHILD ); # ........ if ( not close $something ) { if( not $!{ECHILD} ) { die "Houston, we have a problem: $!"; } else { # Silence is golden; ECHILD is silent. } }

Dave

Replies are listed 'Best First'.
Re^2: Check for "No child processes" internationally
by Anonymous Monk on May 09, 2013 at 06:58 UTC

    # A variation on Errno's POD example: use Errno qw( ECHILD );

    :) Unless you need the number/constant, you don't need to import from Errno

    Also, you don't need to actually use Errno;, using %! in your code will load Errno for you

      Thanks for the tips. :)

      The updated code (removed the 'use', and of course the import):

      # A variation on Errno's POD example: # ........ Do your stuff ........ if ( not close $something ) { if( not $!{ECHILD} ) { die "Houston, we have a problem: $!"; } else { # Silence is golden; ECHILD is silent. } }

      Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1032728]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-25 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found