guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using open-input-output-pipe


From: Matt Wette
Subject: Re: Using open-input-output-pipe
Date: Sun, 21 Jan 2018 16:27:44 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

On 01/21/2018 12:31 PM, Edwin Watkeys wrote:

Hi all,

I'm trying to write a procedure that processes some input through a unix
utility. Open-input-output-pipe returns a bidirectional pipe that I can
both read and write to. However, there is no way that I can figure out to
tell the external process that input is complete, as there is no way to
determine the output port of the rw-port and therefore no way to close it.
Closing an rw-port closes both the read and write ports.

Open-input-output-port therefore seems useful for line-based external
processes but not for ones that function on the entirety of user input e.g.
wc and sort.

Is my analysis of the situation roughly accurate?

Regards,
Edwin

|
||Not pretty, but maybe use `open-output-pipe' and another `pipe' for the input.||
||
||(let* ((ppair (pipe))||
||       (pconn (car pipe))||
||       (iport (cdr pipe))||
||       (oport (open-output-pipe "cmd"))||
||       (save (current-input-port)))||
||  (dynamic-wind||
||    (lambda () (set-current-input-port! pconn))||
||    (lambda ()||
||      ;; write to iport, read from oport||
||      (close iport)||
||      ;; read stuff from oport||
||      (close oport))||
||    (lambda () (set-current-input-port! save))))||
|


reply via email to

[Prev in Thread] Current Thread [Next in Thread]