Subject: Re: double FvwmAuto: fvwm hangs in read()

From: [email-masked] (Paul D. Smith)
Date: 05 May 2000 13:26:20 -0400

%% Dominik Vogt <[email-masked]> writes:

  dv> Then, what can we do?  Is it possible to code this approach:

  dv>  1) select() for all pipes
  dv>  2) handle input from the first changed pipe
  dv>  3) remove the changed pipe and all unchanged ones from the set
  dv>  4) select() again on the remaining pipes, return immediately if
  dv>     no input is available.
  dv>  5) repeat 2-5 until no pipes have input

Sure, but I don't see how this is any better than the simpler approach
of doing the select, processing all the FDs which have changed, then
looping and doing another select.

  dv> I'm not sure how select() works exactly.

It's pretty trivial: you invoke it with a set of FDs you want to wait
for; as soon as data is ready in any one or more of them (or you
timeout, if you set one) select() returns, and bits are set for each of
the FDs with data ready.

In a robust, efficient implementation you'd then process each of the
ready FDs in the set, then loop back around to the select to wait for
more data.  There's no requirement that you _do_ process all that data
(select will just return immediately if one of the FDs in the set has
data when you invoke it, of course) and there's no requirement that you
always select with the same set of FDs; you can change them before every
call if you like.

"Waiting" here, of course, is time spent hanging out in the kernel so
your process is completely idle and not consuming any CPU resources.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]