Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

native exit codes 512 and 2304

by petr999 (Acolyte)
on Jan 20, 2010 at 09:00 UTC ( [id://818402]=perlquestion: print w/replies, xml ) Need Help??

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

I have the fork()ed application which I believe to execute the native Perl code only.
It reports that forks are exiting with codes 512 and 2304 and doesn't if they exit(0) normally.
I'd like to know what do those codes mean. The only thing I notice is: exit after loop.
my STDERR looks detached and I should like to investigate the exit code first. It is reported spontaneously by FCGI::ProcManager, so the only STDERR I can see is in the FastCGI requester logs. There are unsignificant warnings there like the one I mentioned and undefined variable, too.
I expect this to be the memory insufficience: I limited the memory hardly and enhanced the comsumption a bit recently, so I even don't expect a human-readable thing out there.
I tried to grep perl sources for 2304 and had no luck of that.
UPDATE. I have the *CORE::GLOBAL::exit redefined in the BEGIN{} of the main package and after I changed things about variable undeclared, I see it's 65280 now which is CORE::exit(255). Should I seek for that on the code included in %INC? But I consider this inconvinient that I can't google out by those numbers. I think it's reasonable to assume the exit codes reported by the daemon to the console are the shell-explainable. Anyway, if Perl process exits with a non-zero status and the value depends on the runtime error like "label not found" there should be a hash constant defined anywhere to be a human-readable explanation for that, just why not?
Thank you.
Peter Vereshagin

Replies are listed 'Best First'.
Re: native exit codes 512 and 2304
by Corion (Patriarch) on Jan 20, 2010 at 09:34 UTC

    Also see exit and perlvar for $? and how it is constructed in Perl.

      Yes, it probably works differently from what I assumed: Perl does not check if it's possible to allocate memory but tries up to be killed by kernel ( or softlimit by daemontools ).
Re: native exit codes 512 and 2304
by JavaFan (Canon) on Jan 20, 2010 at 10:03 UTC
    512 >> 8 == 2 2304 >> 8 == 9
    So it seems something is doing an 'exit 2' and an 'exit 9'.
Re: native exit codes 512 and 2304
by gmargo (Hermit) on Jan 20, 2010 at 16:12 UTC

    Decode these using the proper definitions from POSIX:

    use POSIX qw(:sys_wait_h); decode_status(512); decode_status(2304); sub decode_status { my ($rc) = @_; print "$rc: normal exit with code ". WEXITSTATUS($rc)."\n" if WIFE +XITED( $rc); print "$rc: terminated with signal ".WTERMSIG( $rc)."\n" if WIFS +IGNALED($rc); print "$rc: stopped with signal ". WSTOPSIG( $rc)."\n" if WIFS +TOPPED( $rc); } __END__ 512: normal exit with code 2 2304: normal exit with code 9
Should look at C
by petr999 (Acolyte) on Jan 20, 2010 at 12:04 UTC
    Seem as got it: I should look at C code for particular numbers.
    But it should be nice to have typical exit codes and their probable explanations as a document to read or look up.
      Here's a quick and dirty way of translating exit codes to their C error strings:
      local $! = 512 >> 8; print "$!\n";
      BUT you should be careful! Not everyone uses the C runtime-library error numbers. Exit codes are application specific, they should be listed in the application documentation.

      Your OS should have these. They are specific to each OS.

Re: native exit codes 512 and 2304
by Anonymous Monk on Jan 20, 2010 at 09:18 UTC
    What makes them native? They're probably specific to FCGI :/
      It's only a my guess: on different runtime error like 'malloc() failed' or any different like 'label not found' the error code may be different?
      Anyway, the CORE::GLOBAL::exit is redefined and there is no CORE::exit() on the FCGI::* sources.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-06-15 01:44 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.