'ruby' exit code 32512

Discussion in 'Ruby' started by jacob@asperasoft.com, Feb 5, 2007.

  1. Guest

    Hi, I was having trouble with what seems to be an inconsistency in
    ruby exit codes. I can explain this best with examples:

    On Windows XP, the command:
    ruby -e 'exit(32512)' || echo hi

    yeilds output (as it seems it should):
    hi

    whereas on Mac OS X Darwin, the same command does not output anything
    (where I expect it to output "hi"). Ruby on OS X behaves as I would
    expect if other exit codes are used.

    "ruby -v" for the windows computer: ruby 1.8.4 (2006-04-14) [i386-
    mswin32]
    "ruby -v" for the mac computer: ruby 1.8.2 (2004-12-25) [universal-
    darwin8.0]


    Thank you ahead of time for help in this matter,

    Jacob
     
    , Feb 5, 2007
    #1
    1. Advertising

  2. Guest

    On Tue, 6 Feb 2007 wrote:

    > Hi, I was having trouble with what seems to be an inconsistency in
    > ruby exit codes. I can explain this best with examples:


    nothing to do with ruby

    man 2 wait
    ...

    WEXITSTATUS(status)

    evaluates to the least significant eight bits of the return code of the child
    which terminated, which may have been set as the argument to a call to
    exit() or _exit() or as the argument for a return statement in the main
    program. This macro can only be evaluated if WIFEXITED returned true.

    ...

    the exit staus in unix is stored in only the first byte of the exit status
    word. and

    32512 => 11111110 0000000
    ^
    ^
    ^
    exit status


    this is one of the beautiful things about windows being non-posix.

    ;-)

    -a
    --
    we can deny everything, except that we have the possibility of being better.
    simply reflect on that.
    - the dalai lama
     
    , Feb 5, 2007
    #2
    1. Advertising

  3. unknown wrote:
    > Hi, I was having trouble with what seems to be an inconsistency in
    > ruby exit codes. I can explain this best with examples:
    >
    > On Windows XP, the command:
    > ruby -e 'exit(32512)' || echo hi
    >
    > yeilds output (as it seems it should):
    > hi
    >
    > whereas on Mac OS X Darwin, the same command does not output anything
    > (where I expect it to output "hi"). Ruby on OS X behaves as I would
    > expect if other exit codes are used.


    Not sure about Windows, but a quick glance through Stevens' _Advanced
    Programming in the UNIX Environment_ reinforces my off-the-cuff
    recollection that POSIX doesn't specify more than allowing an 8-bit exit
    status code to make it through. See the wait(2) manual page for the
    documentation for the WEXITSTATUS(status) macro, which on both OS X and
    Linux specifically mention 8-bits.

    --
    Posted via http://www.ruby-forum.com/.
     
    Mike Fletcher, Feb 5, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FuZHk=?=

    Code to Exit Web App and Exit Internet Explorer

    =?Utf-8?B?U2FuZHk=?=, Aug 3, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    7,948
    =?Utf-8?B?U2FuZHk=?=
    Aug 5, 2005
  2. Joe Smith
    Replies:
    4
    Views:
    66,037
    sandeep1976
    Nov 8, 2006
  3. Replies:
    2
    Views:
    479
    Jeff Epler
    May 31, 2005
  4. QQ
    Replies:
    5
    Views:
    538
    Jonathan Adams
    May 10, 2005
  5. Yujo
    Replies:
    2
    Views:
    421
    Gabriel Genellina
    Apr 10, 2007
Loading...

Share This Page