[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Two way pipe
From: |
Ludovic Courtès |
Subject: |
Re: Two way pipe |
Date: |
Thu, 26 Apr 2007 14:25:05 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
Hi Neil,
Neil Jerram <address@hidden> writes:
> Is there any technical reason for why (ice-9 popen) only provides one
> way pipes? In other words, you can either write to the subprocess, or
> read from it, but not both. Are there extra technical difficulties
> involved with a two way pipe?
Doesn't `OPEN_BOTH' do what you want? However, the manual reads:
Care should be taken with `OPEN_BOTH', a deadlock will occur if
both parent and child are writing, and waiting until the write
completes before doing any reading. Each direction has `PIPE_BUF'
bytes of buffering (*note Ports and File Descriptors::), which
will be enough for small writes, but not for say putting a big
file through a filter.
A socket pair might be suitable, too.
> I have a current requirement to create a subprocess (mplayer in slave
> mode) and then both write to and read from it. And it seems to me
> that this kind of requirement probably isn't uncommon.
>
> Telford Tendys once posted a possible implementation of this at
> http://www.red-bean.com/guile/guile/old/3038.html. Can anyone see any
> problems with that implementation?
No, it looks nice. :-)
It could potentially suffer from the deadlock issue as well, but since
communication with a terminal (via SSH) follows a simple pattern (write
command, read result), I guess deadlocks are unlikely.
Thanks,
Ludovic.
- Two way pipe, Neil Jerram, 2007/04/26
- Re: Two way pipe,
Ludovic Courtès <=