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

System Return Code (was: 256)

by Ras (Acolyte)
on May 19, 2001 at 01:33 UTC ( [id://81640]=perlquestion: print w/replies, xml ) Need Help??

Ras has asked for the wisdom of the Perl Monks concerning the following question:

Does any body knows what happens when you do a system call and it returns 256? Do you know what 256 means? Thanks in advance

Edited 2001-05-18 by Ovid

Replies are listed 'Best First'.
Re: System Return Code (was: 256)
by kschwab (Vicar) on May 19, 2001 at 17:26 UTC
    The perl docs actually do have a good explanation of what the return value from system() is, but it's in "perldoc perlvar" instead of "perldoc -f system". system() returns the value of $? after the wait() is done. Here it is:

     $?      The status returned by the last pipe close, backtick
                 (``) command, or system() operator.  Note that this
                 is the status word returned by the wait() system
                 call (or else is made up to look like it).  Thus,
                 the exit value of the subprocess is actually ($? >>
                 8), and $? & 127 gives which signal, if any, the
                 process died from, and $? & 128 reports whether
                 there was a core dump.  (Mnemonic: similar to sh and
                 ksh.)
    
    Just to clarify, $? >> 8 is bitshifting by 8, which is essentially dividing by 256. So, if you are getting a return val of 256 from system(), your spawned program did an exit(1).
Re: 256
by no_slogan (Deacon) on May 19, 2001 at 01:40 UTC
    You mean...
    $result = system("foo")
    sets $result to 256? It means "foo" returned 1. Read "man foo" to see what that means - probably something went wrong. Or not. I need more information to be helpful.
Re: 256
by Beatnik (Parson) on May 19, 2001 at 01:38 UTC
    AFAIK it's application dependent. system() returns the application status/exit code, so whatever the application passes along as exit code is catcheable in your perl code.
    256 could be anything really :)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-16 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found