Perhaps you should read the description of $! in perlvar if you do not understand.

You are making system calls in your signal handler. By convention, errno gets set by the kernel at the point the system call 'fails', ie when it is interrupted by the signal. Any system calls made inside the signal handler have the potential for altering the value of errno. system calls may change errno, whether successful or not, but the value of errno is only meaningful if the call returned a failure value. The 'easy' answer is to have your handler set $! to EINTR (or text equivalent) before ending.

While on the soapbox, let me remind you that making system calls and altering global variables from within a signal handler (except protected variables) is generally a bad idea (unless the handler is simply a cleanup before exiting). Many things that are 'thread-safe' are not 'signal-handler-safe'. It is usually better to design your code so that all the handler does is set a mutex or protected variable that is checked or waited on in the main portion of the code, or a separate thread.

fnord


In reply to Re: Errno being set to strange values when using IO::Poll by Illuminatus
in thread Errno being set to strange values when using IO::Poll by eest

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.