public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [OT] Interrupting select
@ 2001-05-02 23:44 Peter T. Breuer
  2001-05-06 16:44 ` Stephen Wille Padnos
  0 siblings, 1 reply; 8+ messages in thread
From: Peter T. Breuer @ 2001-05-02 23:44 UTC (permalink / raw)
  To: linux kernel

"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


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [OT] Interrupting select.
@ 2001-05-02 21:46 Laramie Leavitt
  2001-05-02 21:56 ` Peter T. Breuer
  0 siblings, 1 reply; 8+ messages in thread
From: Laramie Leavitt @ 2001-05-02 21:46 UTC (permalink / raw)
  To: Linux Kernel


I think that this is slightly off-topic, but I figure that
someone here knows the answer or where to point me to the
answer.  Please respond privately so the entire list is not
spamed by the response.

I am writing a threaded network daemon using a thread per
connection model (I know, it is not the most effective, but
I can extend it to use a thread per N connections in the future).
That thread waits on a socket using select, or possibly merely
doing a read.  Messages to be written are inserted into a queue
in shared memory.  I am looking for a way to send the thread a 
signal or event to cause the thread to abort the read or select
call when data is available.

I know that it would be possible to create a unix socket
and write a byte to that socket whenever data is available,
but there should be a simpler message or signal that I can 
send to the thread to accomplish the same thing.

Thanks,
Laramie

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2001-05-06 13:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-02 23:44 [OT] Interrupting select Peter T. Breuer
2001-05-06 16:44 ` Stephen Wille Padnos
  -- strict thread matches above, loose matches on Subject: below --
2001-05-02 21:46 Laramie Leavitt
2001-05-02 21:56 ` Peter T. Breuer
2001-05-02 22:21   ` Alan Cox
2001-05-02 23:03     ` Peter T. Breuer
2001-05-03  0:01       ` Alan Cox
2001-05-04 20:59       ` Olaf Dietsche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox