How to change a unamed pipe and socket file descriptors readiness ?
First of all, I'm using Linux Kernel 2.6.16 and GlibC 2.3.6.
I'm writing a program (say 'fwd') which reads data from a unamed pipe
(in future I gonna implement it
with socket support) and write it to another.
For now, I'm reading from STDIN_FILENO file descriptor. First I set it
to O_NONBLOCK with fcntl(),
put it in a fd_set and call select() and test it readiness when
So, I do at shell:
$ cat file.txt | ./fwd
Since STDIN_FILENO is non blocking, I make a loop with read() until it
returns 0, so no more data
is ready to be read.
When I call select() again, it imediately returns telling that
STDIN_FILENO 'is' ready to be read. But read()
tell me there's no more data to be read. So... How can I change (or
reset) it's readiness state?
I don't what to close() this file descriptor... because my interest is
that this 'fwd' application will be
spawned by another daemon which I will pipe(), dup2() and fork() and
execv() it and send a data from
parent to child process ('fwd') time by time... so I need this pipe
open at both ends.
Hope I was clear.
thanks a lot in advance, regards
- Prev by Date: Re: Detecting snprintf
- Next by Date: Re: How to change a unamed pipe and socket file descriptors readiness ?
- Previous by thread: Detecting snprintf
- Next by thread: Re: How to change a unamed pipe and socket file descriptors readiness ?