lkml.org 
[lkml]   [2001]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [OT] Interrupting select
Date
"Mark Hahn wrote:"
> > while (1) {
> > int res = select(n,rfds,wfds,efds,&timeout);
> > if (res > 0)
> > return res; // data or error is expected
> > if (res == 0) {
> > return -ETIME; // timeo in select
> > }
> > }
> >
> > A resounding "no". kill -9 hurts it but it's invulnerable to everything
> > else.
>
> um, shouldn't you be testing for res==-1, as well?
> specifically that condition and errno==EINTR is how I'd expect
> signals to effect the loop...

Possibly .. if so that's the answer. But the man page doesn't say so:

tained in the descriptor sets, which may be zero if the
timeout expires before anything interesting happens. On
error, -1 is returned, and errno is set appropriately;

I assumed that "error" is something like trying to watch for a
negative number or zero descriptors, or having a fd_set that doesn't
contain open fd's. The reason I assumed that is because EINTR is not
listed as a possible:


ERRORS
EBADF An invalid file descriptor was given in one of the
sets.
EINTR A non blocked signal was caught.
EINVAL n is negative.
ENOMEM select was unable to allocate memory for internal
tables.

But I'm willing to give it a try! Thanks!

Now back to your regularly scheduled programs ...

Peter

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:52    [W:0.031 / U:0.440 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site