On Wed, 18 Oct 2000, Brian Craft wrote:

> In the code below, I removed the shutdown() and added the block
> after do_scan() to eliminate the RST. The read() never finds any data.
> If there's no data pending, why does read() have any affect?

EOF is considered pending data... and has to be read.

this first snippet you posted would clear the EOF:

> b.c.
> 
> 
>             fcntl (data_fd, F_SETFL, 1);        /* set non-blocking */
>         /*    shutdown (data_fd, 0); */
>             do_scan (w, h, data_fd);
>             {       
>                 char buff[10];
>                 int i, c;
>                 printf("looking for extra data\n");
>                 while ((c = read(data_fd, buff, 10)) >= 0) {
>                     if (c > 0) {
>                         for (i=0; i<c; ++i) {
>                             printf("%x ", buff[i]); 
>                         }           
>                         printf("\n");
>                     }           
>                 }           
>                 printf("no more data\n");
>             }           
>             close (data_fd);


but in this next message with the "st" program, the read() doesn't clear
the EOF...

On Wed, 18 Oct 2000, Brian Craft wrote:

>         while (count < LEN) {
>             n = read(fd, buff, 100);
>             if (n < 0) {
>                 printf("error on read\n");
>                 break;
>             }
>             count += n;
>         }

you need one more read() to clear the EOF.



i'm not saying this totally explains the problems you're seeing, but i
think it's suspect.

-dean


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to