* Two way pipe
@ 2007-04-26 7:31 Neil Jerram
2007-04-26 12:25 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: Neil Jerram @ 2007-04-26 7:31 UTC (permalink / raw)
To: Guile Users
Hi all,
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?
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?
Regards,
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Two way pipe
2007-04-26 7:31 Two way pipe Neil Jerram
@ 2007-04-26 12:25 ` Ludovic Courtès
2007-04-26 20:49 ` Neil Jerram
0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2007-04-26 12:25 UTC (permalink / raw)
To: Neil Jerram; +Cc: Guile Users
Hi Neil,
Neil Jerram <neil@ossau.uklinux.net> 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.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Two way pipe
2007-04-26 12:25 ` Ludovic Courtès
@ 2007-04-26 20:49 ` Neil Jerram
2007-04-27 8:09 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: Neil Jerram @ 2007-04-26 20:49 UTC (permalink / raw)
To: Guile Users
ludovic.courtes@laas.fr (Ludovic Courtès) writes:
> Doesn't `OPEN_BOTH' do what you want?
Yes, indeed. Believe it or not, I was looking at a 1.6 distribution
and didn't think to check 1.8 or CVS. (Newbie alert! :-))
> 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.
So far I've been playing with (open-input-pipe "mplayer -slave ..."),
but not bothering to select on and read from the pipe. If the track
being played is longer than about 3 minutes, mplayer crashes - and I
assume that's because its write to stdout is failing unexpectedly. So
for some programs, it seems that filling up the pipe buffer can be a
problem even if in only one direction.
When I implement things fully this won't be a problem, because the
Guile app will be reading any available data from the pipe as soon as
it's there, and only very rarely writing anything.
Many thanks,
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Two way pipe
2007-04-26 20:49 ` Neil Jerram
@ 2007-04-27 8:09 ` Ludovic Courtès
0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2007-04-27 8:09 UTC (permalink / raw)
To: Neil Jerram; +Cc: Guile Users
Hello!
Neil Jerram <neil@ossau.uklinux.net> writes:
> ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>
>> Doesn't `OPEN_BOTH' do what you want?
>
> Yes, indeed. Believe it or not, I was looking at a 1.6 distribution
> and didn't think to check 1.8 or CVS. (Newbie alert! :-))
Oh, gosh, I thought you were using cutting-edge technology! ;-)
> So far I've been playing with (open-input-pipe "mplayer -slave ..."),
> but not bothering to select on and read from the pipe. If the track
> being played is longer than about 3 minutes, mplayer crashes - and I
> assume that's because its write to stdout is failing unexpectedly. So
> for some programs, it seems that filling up the pipe buffer can be a
> problem even if in only one direction.
How does it crash? `EPIPE' or some such?
> When I implement things fully this won't be a problem, because the
> Guile app will be reading any available data from the pipe as soon as
> it's there, and only very rarely writing anything.
Ok. Out of curiosity, are you trying to write a Guile front-end (if
that's not too much of a nosy question)?
Thanks,
Ludovic.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-27 8:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-26 7:31 Two way pipe Neil Jerram
2007-04-26 12:25 ` Ludovic Courtès
2007-04-26 20:49 ` Neil Jerram
2007-04-27 8:09 ` Ludovic Courtès
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 read-only IMAP folder(s) and NNTP newsgroup(s).