>Would someone please write me a code snippet which shows the proper
>usage of the select function when used to wait for data to be sent to a fifo 
>from kernel-space. 

Here you are:
 
 
 fd_set rfds;          
 int fd_control,fd_data,fd_error;   

 if ((fd_data = open(RT_FIFO_DATA, O_RDONLY)) < 0) {
    fprintf(stderr, "Error opening " RT_FIFO_DATA "\n");
    exit(1);
  }

  if ((fd_error = open(RT_FIFO_ERROR, O_RDONLY)) < 0) {
    fprintf(stderr, "Error opening " RT_FIFO_ERROR "\n");
    exit(1);
  }

   /* Wait for data showing up in either fd_data or fd_error
       no time-outs. For time-outs look at the according manpage 
       man 2 select */
    FD_ZERO(&rfds);
    FD_SET(fd_data, &rfds);
    FD_SET(fd_error, &rfds);
    select(FD_SETSIZE, &rfds, NULL, NULL, NULL);

    if (FD_ISSET(fd_data, &rfds)) { // got data from in fd_data 
        ...
    }
  
    if (FD_ISSET(fd_error, &rfds)) { // got data from in fd_error 
        ...
    }

>Does select to a busy-wait?
No.


-- 
[EMAIL PROTECTED]
PGP key: http://www.math.uni-goettingen.de/appel/jappel.pgp
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to