Bug Hunter wrote:

> > >     we opened a pipe without error.  we then did this:
> > >         FD_ZERO(&InputFD);        // initialize read descriptors
> > >
> > >         FD_SET(s,&InputFD);       // Add socket to descriptors to
> > >         FD_SET(FromDH,&InputFD);  // wait on Modem data as well
> > >
> > >         FD_ZERO(&wErrorFD);
> > >         FD_SET(s,&wErrorFD);
> > >         FD_SET(FromDH, &wErrorFD);
> > >
> > >         signal(SIGALRM,SignalHandler);
> > >
> > >         while(1){
> > >                 wInputFD = InputFD;
> > >                 // don't wait more than 500msec before reporting
> > >                 timeout.tv_sec = 0;
> > >                 timeout.tv_usec = 500000;
> > >                 short result = 
>select(FD_SETSIZE,&wInputFD,NULL,&wErrorFD,&timeout);
> > > ...
> > >
> > >
> > >     We get a 2 from select, then the pipe (FromDH) indicates
> > > an error.  errno is zero.  There is no error that we can
> > > see.  any clues?
> >
> > What do you mean that the pipe `indicates an error'?
> >
> > Note that the third fd_set (fourth argument to select) indicates
> > `exceptional conditions', not necessarily errors.
> >
> > Also, errno is only set if some library function indicates an error
> > (usually by returning -1, NULL, etc). If select() returns 2, then it
> > won't have set errno.
> 
>     Im sorry, I phrased that badly.  wErrorFD indicates an exception for the pipe:
> 
>     if (FD_ISSET(FromDH,&wErrorFD) )
>     {
>     /* error */
>     }
> 
> This always takes the error for the pipe. I don't get this for the
> other handles. Is there something special about pipes that indicate
> an exception??
> 
>     When we opened the pipe, there were no problems.  We opened the pipe like this:
> 
>                 FromDH=open(FROMDH_PIPE,O_RDONLY | O_NONBLOCK);
>                 if(FromDH<0){
>                         printf("Error in %s at %d =>",__FILE__,__LINE__);
>                         perror("Can't open FromDH");
>                         exit(errno);
>                 }
>     and no error was caught.  errno stayed 0.

I don't think that you should use select() on descriptors which are
non-blocking. You would normally either use select() or non-blocking
I/O, but not both.

This *may* be what's causing select() to indicate an exceptional
condition on FromDH.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to