linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* select() and pipes
@ 2002-11-28 14:48 William N. Zanatta
  2002-11-28 15:31 ` Glynn Clements
  0 siblings, 1 reply; 2+ messages in thread
From: William N. Zanatta @ 2002-11-28 14:48 UTC (permalink / raw)
  To: linux-c-programming


   Hi,

   I'm writing a tiny program which gets its input from a pipe. It works 
with apache like in this example...

------ httpd.conf-------

   CustomLog "|/path/my/bin"

------ httpd.conf-------

   On apache2 it works pretty well but on 1.3 series I'm experiencing 
some problemas and one of them is the CPU Load. The program's main() 
used to live in a infinite loop making a fgets() and checking for data 
availability on the returned buffer.

   Well, guessing this is the main reason for the CPU Load, I started 
with select() to check for data availability and I've found that the 
couple select() and the pipe as stdin will always return a ready to read 
status even if there's no data to be read.

   How does it work internally? How could I minimize the cpu load? 
Should  I use named pipes instead and tell apache to throw logs there?

   Thanks,

william


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

* Re: select() and pipes
  2002-11-28 14:48 select() and pipes William N. Zanatta
@ 2002-11-28 15:31 ` Glynn Clements
  0 siblings, 0 replies; 2+ messages in thread
From: Glynn Clements @ 2002-11-28 15:31 UTC (permalink / raw)
  To: William N. Zanatta; +Cc: linux-c-programming


William N. Zanatta wrote:

>    I'm writing a tiny program which gets its input from a pipe. It works 
> with apache like in this example...
> 
> ------ httpd.conf-------
> 
>    CustomLog "|/path/my/bin"
> 
> ------ httpd.conf-------
> 
>    On apache2 it works pretty well but on 1.3 series I'm experiencing 
> some problemas and one of them is the CPU Load. The program's main() 
> used to live in a infinite loop making a fgets() and checking for data 
> availability on the returned buffer.
> 
>    Well, guessing this is the main reason for the CPU Load, I started 
> with select() to check for data availability and I've found that the 
> couple select() and the pipe as stdin will always return a ready to read 
> status even if there's no data to be read.

How exactly are you using select()? Are you initialising the fd_set
correctly? Are you specifying a timeout?

Is there any reason why you can't just perform blocking reads?

-- 
Glynn Clements <glynn.clements@virgin.net>

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

end of thread, other threads:[~2002-11-28 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-28 14:48 select() and pipes William N. Zanatta
2002-11-28 15:31 ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).