An addendum: (BTW, I'm running in Solaris8.) After posting this, I ran yet more tests, and discovered that when I run system() with just one argument, thus invoking shell interpolation, the return code from system() is reorganized.

Programming Perl (page 812) describes the system() return value as follows (for system with a LIST argument):

$exit_value = $? >> 8; $signal_num = $? & 127; # or 0x7f ... $dumped_core = $? & 128; # or 0x80 ...

I.e. the return status is in the HIGH byte, and the signal received, and coredump status, are encoded in the LO byte.

But in the single argument form of system(), I notice that the LO byte has nothing in it. The HIGH byte seems to be encoded as follows:

$high_byte = $? >> 8; $was_interrupted = $high_byte & 0x80; $status = $high_byte & 0x7f;
If $was_interrupted is 0, then $status is the return status of the shell command. If $was_interrupted is 1, then $status is the signal number that interrupted the child shell.

I'm posting this because I haven't seen this documented anywhere. Does anyone know this stuff already? Where (if at all) is this documented? Is this a Solaris feature, or a Perl feature??

thanks!
-cadphile


In reply to Re: SIGINT in system() with shell metachars by cadphile
in thread SIGINT in system() with shell metachars by cadphile

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.