[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: popen read and write?
- From: Edgar Toernig <froese@...>
- Date: Thu, 11 Oct 2007 01:09:13 +0200
Duck wrote:
>
> Anything of Steve's popen2 sort is prone to deadlock, [...]
Yes and no. Yes because he has based his popen2 on stdio and
provides nothing but blocking read and write. No because you
can make it deadlock free by either providing non-blocking
read and write together with a select like function, or you
create threads, one for reading and one for writing.
I.e. glib's popen2 (with that looong name) looks like a solid
base. Together with its io-queues and the select-based main
loop you have everything to get deadlock-free bidirectional
communication.
> I had in mind extending Steve's code (and may yet do it) in order to:
> [...]
> 2. Provide for a "peek" method which portably allows you to see whether a
> read is going to block.
And how do you "peek" into stdio's input buffer?
Ciao, ET.