Well.. if the while loop keeps me from receiving the signal, then I dont understand signals anymore.. ! ;-). Concerning select - as you say - it hangs the program waiting for input, meaning I cannot do anything else but just waiting in the meantime.

Otherwise, yes I have checked the HOWTO and allready knew it (I usually read the Serial Programing HOWTO at linuxdoc.org. Just for the record, actually I think there is a small flaw in its Asynchrounous Input example (here under is a small snipet from it):

while (STOP==FALSE) { printf(".\n");usleep(100000); /* after receiving SIGIO, wait_flag = FALSE, input is available and can be read */ if (wait_flag==FALSE) { res = read(fd,buf,255); buf[res]=0; printf(":%s:%d\n", buf, res); if (res==1) STOP=TRUE; /* stop loop if only a CR was input */ wait_flag = TRUE; /* wait for new input */ } }

Before this while loop a signal handler was installed, which will set wait_flag to FALSE if a signal arrives. With this code, when a signal arrives the buffer will be read, resetted, and printed out before setting wait_flag back to TRUE again. But what if some data comes to the port when it is printing out? The signal handler will set wait_flag to FALSE, and the loop will set it back to TRUE again afther testing for res.. I think I might just end up waiting (forever) for input that was allready there.. (?)


In reply to Re: Re: Re: Re: Handling I/O Signals by stephane
in thread Handling I/O Signals by stephane

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.