unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#15228: [PATCH] Close output port of I/O pipes
@ 2013-08-31  8:29 Josep Portella Florit
  2016-06-21 10:47 ` Andy Wingo
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Josep Portella Florit @ 2013-08-31  8:29 UTC (permalink / raw)
  To: 15228

There is a missing feature for pipes created with mode OPEN_BOTH:

(use-modules (ice-9 popen))
(use-modules (rnrs io ports))

(let ((p (open-pipe "md5sum" OPEN_BOTH)))
  (put-string p "hello")
  (let ((x (get-string-all p)))
    (close-pipe p)
    x))

This code deadlocks in get-string-all because md5sum, like other
filters, keeps waiting for input until the pipe's output port is
closed.

The output port can't be closed without closing the input port too,
because an I/O pipe is a soft port that doesn't store the 2 ports
returned by open-process, but a thunk which closes both ports.

This is now possible with the new procedure close-pipe-output:

(let ((p (open-pipe "md5sum" OPEN_BOTH)))
  (put-string p "hello")
  (close-pipe-output p)
  (let ((x (get-string-all p)))
    (close-pipe p)
    x))
;; => "5d41402abc4b2a76b9719d911017c592  -\n"

The intention is to make a backwards compatible and minimal change
that makes it possible to write to and read from pipes for filters
like md5sum without temporary files.

Changes involved:

* module/ice-9/popen.scm: Define a weak hash-table for mapping I/O pipes to
  their output ports, change make-rw-port to use it, define the
  close-pipe-output procedure and export it.

* doc/ref/posix.texi: Add documentation for close-pipe-output.

On garbage collection the new hash-table is updated as expected:

scheme@(ice-9 popen)> rw/w-table
$3 = #<weak-key-hash-table 8b8a930 0/31>
scheme@(ice-9 popen)> (define p (open-pipe "md5sum" OPEN_BOTH))
scheme@(ice-9 popen)> rw/w-table
$4 = #<weak-key-hash-table 8b8a930 1/31>
scheme@(ice-9 popen)> (set! p #f)
scheme@(ice-9 popen)> (gc)
scheme@(ice-9 popen)> rw/w-table
$5 = #<weak-key-hash-table 8b8a930 0/31>

Maybe there is a better name for the new procedure.
---
 doc/ref/posix.texi     |    6 ++++++
 module/ice-9/popen.scm |   39 +++++++++++++++++++++++++++++----------
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index b3a6a04..f0c6ca1 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -2312,6 +2312,12 @@ terminate, and return the wait status code.  The status is as per
 (@pxref{Processes})
 @end deffn
 
+@deffn {Scheme Procedure} close-pipe-output port
+Close the output port of a pipe created by @code{open-pipe} with
+mode @code{OPEN_BOTH}, and leave the input port open.  Return `#t' if
+the port is closed successfully or `#f' if it was already closed.
+@end deffn
+
 @sp 1
 @code{waitpid WAIT_ANY} should not be used when pipes are open, since
 it can reap a pipe's child process, causing an error from a subsequent
diff --git a/module/ice-9/popen.scm b/module/ice-9/popen.scm
index 7d0549e..2b014c5 100644
--- a/module/ice-9/popen.scm
+++ b/module/ice-9/popen.scm
@@ -18,22 +18,32 @@
 ;;;; 
 
 (define-module (ice-9 popen)
-  :export (port/pid-table open-pipe* open-pipe close-pipe open-input-pipe
-	   open-output-pipe open-input-output-pipe))
+  :export (port/pid-table open-pipe* open-pipe close-pipe close-pipe-output
+           open-input-pipe open-output-pipe open-input-output-pipe))
 
 (eval-when (load eval compile)
   (load-extension (string-append "libguile-" (effective-version))
                   "scm_init_popen"))
 
+;; a weak hash-table to store the write port of read-write pipes
+;; just to be able to retrieve it in close-pipe-output.
+(define rw/w-table (make-weak-key-hash-table 31))
+
 (define (make-rw-port read-port write-port)
-  (make-soft-port
-   (vector
-    (lambda (c) (write-char c write-port))
-    (lambda (s) (display s write-port))
-    (lambda () (force-output write-port))
-    (lambda () (read-char read-port))
-    (lambda () (close-port read-port) (close-port write-port)))
-   "r+"))
+  (letrec ((port (make-soft-port
+                  (vector
+                   (lambda (c) (write-char c write-port))
+                   (lambda (s) (display s write-port))
+                   (lambda () (force-output write-port))
+                   (lambda () (read-char read-port))
+                   (lambda ()
+                     (hashq-remove! rw/w-table port)
+                     (close-port read-port)
+                     (or (port-closed? write-port)
+                         (close-port write-port))))
+                  "r+")))
+    (hashq-set! rw/w-table port write-port)
+    port))
 
 ;; a guardian to ensure the cleanup is done correctly when
 ;; an open pipe is gc'd or a close-port is used.
@@ -106,6 +116,15 @@ information on how to interpret this value."
         (error "close-pipe: pipe not in table"))
     (close-process (cons p pid))))
 
+(define (close-pipe-output pipe)
+  "Closes the output port of a pipe created by @code{open-pipe} with
+mode @code{OPEN_BOTH}, and leaves the input port open.  Returns `#t' if
+it successfully closes the port or `#f' if it was already closed."
+  (let ((port (hashq-ref rw/w-table pipe)))
+    (unless port
+      (error "close-pipe-output: pipe not in table"))
+    (close-port port)))
+
 (define reap-pipes
   (lambda ()
     (let loop ((p (pipe-guardian)))
-- 
1.7.9.5







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#15228: [PATCH] Close output port of I/O pipes
  2013-08-31  8:29 bug#15228: [PATCH] Close output port of I/O pipes Josep Portella Florit
@ 2016-06-21 10:47 ` Andy Wingo
  2016-09-03  7:33 ` bug#15228: making open-process public Amirouche Boubekki
  2021-06-02  5:45 ` bug#15228: can this be closed ? Adriano Peluso
  2 siblings, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2016-06-21 10:47 UTC (permalink / raw)
  To: Josep Portella Florit; +Cc: 15228, guile-devel

Hi :)

I dunno how much we should push this "processes are a single port"
abstraction.  In many ways for OPEN_BOTH pipes it's easier to deal with
an input and an output port and a PID instead of the pipe abstraction.
WDYT?  We could just expose `open-process' from (ice-9 popen) to start
with.  It would be good to allow other fd's or ports to map to the child
as well, e.g. stderr or any particular port; but I don't know what
interface we should expose.

Thoughts?

Andy

On Sat 31 Aug 2013 10:29, Josep Portella Florit <jpf@primfilat.com> writes:

> There is a missing feature for pipes created with mode OPEN_BOTH:
>
> (use-modules (ice-9 popen))
> (use-modules (rnrs io ports))
>
> (let ((p (open-pipe "md5sum" OPEN_BOTH)))
>   (put-string p "hello")
>   (let ((x (get-string-all p)))
>     (close-pipe p)
>     x))
>
> This code deadlocks in get-string-all because md5sum, like other
> filters, keeps waiting for input until the pipe's output port is
> closed.
>
> The output port can't be closed without closing the input port too,
> because an I/O pipe is a soft port that doesn't store the 2 ports
> returned by open-process, but a thunk which closes both ports.
>
> This is now possible with the new procedure close-pipe-output:
>
> (let ((p (open-pipe "md5sum" OPEN_BOTH)))
>   (put-string p "hello")
>   (close-pipe-output p)
>   (let ((x (get-string-all p)))
>     (close-pipe p)
>     x))
> ;; => "5d41402abc4b2a76b9719d911017c592  -\n"
>
> The intention is to make a backwards compatible and minimal change
> that makes it possible to write to and read from pipes for filters
> like md5sum without temporary files.
>
> Changes involved:
>
> * module/ice-9/popen.scm: Define a weak hash-table for mapping I/O pipes to
>   their output ports, change make-rw-port to use it, define the
>   close-pipe-output procedure and export it.
>
> * doc/ref/posix.texi: Add documentation for close-pipe-output.
>
> On garbage collection the new hash-table is updated as expected:
>
> scheme@(ice-9 popen)> rw/w-table
> $3 = #<weak-key-hash-table 8b8a930 0/31>
> scheme@(ice-9 popen)> (define p (open-pipe "md5sum" OPEN_BOTH))
> scheme@(ice-9 popen)> rw/w-table
> $4 = #<weak-key-hash-table 8b8a930 1/31>
> scheme@(ice-9 popen)> (set! p #f)
> scheme@(ice-9 popen)> (gc)
> scheme@(ice-9 popen)> rw/w-table
> $5 = #<weak-key-hash-table 8b8a930 0/31>
>
> Maybe there is a better name for the new procedure.
> ---
>  doc/ref/posix.texi     |    6 ++++++
>  module/ice-9/popen.scm |   39 +++++++++++++++++++++++++++++----------
>  2 files changed, 35 insertions(+), 10 deletions(-)
>
> diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
> index b3a6a04..f0c6ca1 100644
> --- a/doc/ref/posix.texi
> +++ b/doc/ref/posix.texi
> @@ -2312,6 +2312,12 @@ terminate, and return the wait status code.  The status is as per
>  (@pxref{Processes})
>  @end deffn
>  
> +@deffn {Scheme Procedure} close-pipe-output port
> +Close the output port of a pipe created by @code{open-pipe} with
> +mode @code{OPEN_BOTH}, and leave the input port open.  Return `#t' if
> +the port is closed successfully or `#f' if it was already closed.
> +@end deffn
> +
>  @sp 1
>  @code{waitpid WAIT_ANY} should not be used when pipes are open, since
>  it can reap a pipe's child process, causing an error from a subsequent
> diff --git a/module/ice-9/popen.scm b/module/ice-9/popen.scm
> index 7d0549e..2b014c5 100644
> --- a/module/ice-9/popen.scm
> +++ b/module/ice-9/popen.scm
> @@ -18,22 +18,32 @@
>  ;;;; 
>  
>  (define-module (ice-9 popen)
> -  :export (port/pid-table open-pipe* open-pipe close-pipe open-input-pipe
> -	   open-output-pipe open-input-output-pipe))
> +  :export (port/pid-table open-pipe* open-pipe close-pipe close-pipe-output
> +           open-input-pipe open-output-pipe open-input-output-pipe))
>  
>  (eval-when (load eval compile)
>    (load-extension (string-append "libguile-" (effective-version))
>                    "scm_init_popen"))
>  
> +;; a weak hash-table to store the write port of read-write pipes
> +;; just to be able to retrieve it in close-pipe-output.
> +(define rw/w-table (make-weak-key-hash-table 31))
> +
>  (define (make-rw-port read-port write-port)
> -  (make-soft-port
> -   (vector
> -    (lambda (c) (write-char c write-port))
> -    (lambda (s) (display s write-port))
> -    (lambda () (force-output write-port))
> -    (lambda () (read-char read-port))
> -    (lambda () (close-port read-port) (close-port write-port)))
> -   "r+"))
> +  (letrec ((port (make-soft-port
> +                  (vector
> +                   (lambda (c) (write-char c write-port))
> +                   (lambda (s) (display s write-port))
> +                   (lambda () (force-output write-port))
> +                   (lambda () (read-char read-port))
> +                   (lambda ()
> +                     (hashq-remove! rw/w-table port)
> +                     (close-port read-port)
> +                     (or (port-closed? write-port)
> +                         (close-port write-port))))
> +                  "r+")))
> +    (hashq-set! rw/w-table port write-port)
> +    port))
>  
>  ;; a guardian to ensure the cleanup is done correctly when
>  ;; an open pipe is gc'd or a close-port is used.
> @@ -106,6 +116,15 @@ information on how to interpret this value."
>          (error "close-pipe: pipe not in table"))
>      (close-process (cons p pid))))
>  
> +(define (close-pipe-output pipe)
> +  "Closes the output port of a pipe created by @code{open-pipe} with
> +mode @code{OPEN_BOTH}, and leaves the input port open.  Returns `#t' if
> +it successfully closes the port or `#f' if it was already closed."
> +  (let ((port (hashq-ref rw/w-table pipe)))
> +    (unless port
> +      (error "close-pipe-output: pipe not in table"))
> +    (close-port port)))
> +
>  (define reap-pipes
>    (lambda ()
>      (let loop ((p (pipe-guardian)))





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#15228: making open-process public
  2013-08-31  8:29 bug#15228: [PATCH] Close output port of I/O pipes Josep Portella Florit
  2016-06-21 10:47 ` Andy Wingo
@ 2016-09-03  7:33 ` Amirouche Boubekki
  2017-02-28  9:58   ` Andy Wingo
  2017-03-05 20:41   ` Amirouche
  2021-06-02  5:45 ` bug#15228: can this be closed ? Adriano Peluso
  2 siblings, 2 replies; 7+ messages in thread
From: Amirouche Boubekki @ 2016-09-03  7:33 UTC (permalink / raw)
  To: 15228

Wingo wrote:

> We could just expose `open-process' from (ice-9 popen) to start with.

AFAIK, that's what Mark wants.

Here is an example use of `open-process' to wrap `html2text':


    (use-modules (ice-9 popen))

    (define open-process (@@ (ice-9 popen) open-process))

    (define (html2text string)
      (with-error-to-file "/dev/null"
        (lambda ()
          (call-with-values (lambda () (open-process OPEN_BOTH 
"html2text"))
            (lambda (read-port write-port pid)
              (display string write-port)
              (close-port write-port)
              (let ((str (read-string read-port)))
                (close-port read-port)
                (waitpid pid)
                str))))))

IIUC to achieve this goal, I need to make `open-process' public
in `ice-9 popen` module and add documentation for it?

Is that correct?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#15228: making open-process public
  2016-09-03  7:33 ` bug#15228: making open-process public Amirouche Boubekki
@ 2017-02-28  9:58   ` Andy Wingo
  2017-03-05 20:41   ` Amirouche
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2017-02-28  9:58 UTC (permalink / raw)
  To: Amirouche Boubekki; +Cc: 15228

On Sat 03 Sep 2016 09:33, Amirouche Boubekki <amirouche@hypermove.net> writes:

>> We could just expose `open-process' from (ice-9 popen) to start with.
>
> Here is an example use of `open-process' to wrap `html2text':
>
>
>    (use-modules (ice-9 popen))
>
>    (define open-process (@@ (ice-9 popen) open-process))
>
>    (define (html2text string)
>      (with-error-to-file "/dev/null"
>        (lambda ()
>          (call-with-values (lambda () (open-process OPEN_BOTH
> "html2text"))
>            (lambda (read-port write-port pid)
>              (display string write-port)
>              (close-port write-port)
>              (let ((str (read-string read-port)))
>                (close-port read-port)
>                (waitpid pid)
>                str))))))
>
> IIUC to achieve this goal, I need to make `open-process' public
> in `ice-9 popen` module and add documentation for it?
>
> Is that correct?

Yep!  Let's just do this.  Would you mind sending a patch.

Andy





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#15228: making open-process public
  2016-09-03  7:33 ` bug#15228: making open-process public Amirouche Boubekki
  2017-02-28  9:58   ` Andy Wingo
@ 2017-03-05 20:41   ` Amirouche
  1 sibling, 0 replies; 7+ messages in thread
From: Amirouche @ 2017-03-05 20:41 UTC (permalink / raw)
  To: 15228

[-- Attachment #1: Type: text/plain, Size: 1080 bytes --]

Sorry I have an issue with my mail I can't find the mail where you asked 
for a patch.

Attached to this mail my very first patch.


Le 03/09/2016 à 09:33, Amirouche Boubekki a écrit :
> Wingo wrote:
>
>> We could just expose `open-process' from (ice-9 popen) to start with.
>
> AFAIK, that's what Mark wants.
>
> Here is an example use of `open-process' to wrap `html2text':
>
>
>    (use-modules (ice-9 popen))
>
>    (define open-process (@@ (ice-9 popen) open-process))
>
>    (define (html2text string)
>      (with-error-to-file "/dev/null"
>        (lambda ()
>          (call-with-values (lambda () (open-process OPEN_BOTH 
> "html2text"))
>            (lambda (read-port write-port pid)
>              (display string write-port)
>              (close-port write-port)
>              (let ((str (read-string read-port)))
>                (close-port read-port)
>                (waitpid pid)
>                str))))))
>
> IIUC to achieve this goal, I need to make `open-process' public
> in `ice-9 popen` module and add documentation for it?
>
> Is that correct?
>
>
>


[-- Attachment #2: 0002-make-open-process-public-in-ice-9-popen.patch --]
[-- Type: text/x-patch, Size: 4399 bytes --]

From 997e521e2368c771822b9741e47850665f7715f1 Mon Sep 17 00:00:00 2001
From: Amirouche <amirouche@hypermove.net>
Date: Sun, 5 Mar 2017 21:37:09 +0100
Subject: [PATCH 2/2] make open-process public in (ice-9 popen)

---
 doc/ref/posix.texi     | 60 ++++++++++++++++++++++++++++++++++++++++++--------
 module/ice-9/popen.scm |  2 +-
 2 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 4afe6bf..53f2230 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -2161,12 +2161,12 @@ expiry will be signalled.
 A real-time timer, counting down elapsed real time.  At zero it raises
 @code{SIGALRM}.  This is like @code{alarm} above, but with a higher
 resolution period.
-@end defvar 
+@end defvar
 
 @defvar ITIMER_VIRTUAL
 A virtual-time timer, counting down while the current process is
 actually using CPU.  At zero it raises @code{SIGVTALRM}.
-@end defvar 
+@end defvar
 
 @defvar ITIMER_PROF
 A profiling timer, counting down while the process is running (like
@@ -2175,7 +2175,7 @@ process's behalf.  At zero it raises a @code{SIGPROF}.
 
 This timer is intended for profiling where a program is spending its
 time (by looking where it is when the timer goes off).
-@end defvar 
+@end defvar
 
 @code{getitimer} returns the restart timer value and its current value,
 as a list containing two pairs.  Each pair is a time in seconds and
@@ -2260,6 +2260,48 @@ module@footnote{This module is only available on systems where the
 (use-modules (ice-9 popen))
 @end lisp
 
+@findex open-process
+@deffn {Scheme Procedure} open-process mode command [args...]
+
+Execute @code{command} in a subprocess passing @code{args} as arguments.
+
+@code{open-process} is the procedure used by and @code{open-pipe}
+and else to communicate with a subprocess using pipes. The notable
+difference with @code{open-pipe} API is that @code{open-process}
+does return multiple values.
+
+It returns @code{read-port}, @code{write-port} and @code{pid}. Depending
+on the @code{mode} you open the subprocess you can access
+@code{read-port} and @code{write-port} using regular port procedures.
+In particular you can close the @code{read-port} without closing the
+@code{write-port}. Don't forget to call @code{waitpid} on @code{pid}.
+
+Here is an example program that calls @code{tr} that request to replace
+@code{qsdf} with @code{asdf}:
+
+@lisp
+(use-modules (ice-9 rdelim))
+(use-modules (ice-9 popen))
+
+
+(define open-process (@@ (ice-9 popen) open-process))
+
+(define (qsdf->asdf string)
+  (call-with-values (lambda () (open-process OPEN_BOTH "tr" "qsdf" "asdf"))
+    (lambda (read-port write-port pid)
+      (display string write-port)
+      (close-port write-port)
+      (let ((str (read-string read-port)))
+        (close-port read-port)
+        (waitpid pid)
+        str))))
+
+
+(pk (qsdf->asdf "qsdf is fun!"))
+@result{} "asdf is fun!"
+@end lisp
+@end deffn
+
 @findex popen
 @deffn {Scheme Procedure} open-pipe command mode
 @deffnx {Scheme Procedure} open-pipe* mode prog [args...]
@@ -2356,11 +2398,11 @@ the garbage collector pick them up at some later time.
 @cindex network
 
 @menu
-* Network Address Conversion::  
-* Network Databases::           
-* Network Socket Address::      
-* Network Sockets and Communication::  
-* Internet Socket Examples::    
+* Network Address Conversion::
+* Network Databases::
+* Network Socket Address::
+* Network Sockets and Communication::
+* Internet Socket Examples::
 @end menu
 
 @node Network Address Conversion
@@ -3167,7 +3209,7 @@ effect but the value in Guile is always a pair.
 
 @c  Note that we refer only to ``man ip'' here.  On GNU/Linux it's
 @c  ``man 7 ip'' but on NetBSD it's ``man 4 ip''.
-@c 
+@c
 For IP level (@code{IPPROTO_IP}) the following @var{optname}s are
 defined (when provided by the system).  See @command{man ip} for what
 they mean.
diff --git a/module/ice-9/popen.scm b/module/ice-9/popen.scm
index 26a7e0a..37ea068 100644
--- a/module/ice-9/popen.scm
+++ b/module/ice-9/popen.scm
@@ -22,7 +22,7 @@
   :use-module (ice-9 threads)
   :use-module (srfi srfi-9)
   :export (port/pid-table open-pipe* open-pipe close-pipe open-input-pipe
-	   open-output-pipe open-input-output-pipe))
+	   open-output-pipe open-input-output-pipe open-process))
 
 (eval-when (expand load eval)
   (load-extension (string-append "libguile-" (effective-version))
-- 
2.9.3


[-- Attachment #3: 0001-whitespace-cleanup.patch --]
[-- Type: text/x-patch, Size: 1666 bytes --]

From ae9587457b502234fc137644a12bbd754e6fdc0c Mon Sep 17 00:00:00 2001
From: Amirouche <amirouche@hypermove.net>
Date: Sun, 5 Mar 2017 21:38:27 +0100
Subject: [PATCH 1/2] whitespace cleanup

---
 module/ice-9/popen.scm | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/module/ice-9/popen.scm b/module/ice-9/popen.scm
index b166e9d..26a7e0a 100644
--- a/module/ice-9/popen.scm
+++ b/module/ice-9/popen.scm
@@ -2,21 +2,21 @@
 
 ;;;; Copyright (C) 1998, 1999, 2000, 2001, 2003, 2006, 2010, 2011, 2012,
 ;;;;   2013 Free Software Foundation, Inc.
-;;;; 
+;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
 ;;;; License as published by the Free Software Foundation; either
 ;;;; version 3 of the License, or (at your option) any later version.
-;;;; 
+;;;;
 ;;;; This library is distributed in the hope that it will be useful,
 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 ;;;; Lesser General Public License for more details.
-;;;; 
+;;;;
 ;;;; You should have received a copy of the GNU Lesser General Public
 ;;;; License along with this library; if not, write to the Free Software
 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;;;; 
+;;;;
 
 (define-module (ice-9 popen)
   :use-module (ice-9 threads)
@@ -144,4 +144,3 @@ information on how to interpret this value."
 (define (open-input-output-pipe command)
   "Equivalent to @code{open-pipe} with mode @code{OPEN_BOTH}"
   (open-pipe command OPEN_BOTH))
-
-- 
2.9.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#15228: can this be closed ?
  2013-08-31  8:29 bug#15228: [PATCH] Close output port of I/O pipes Josep Portella Florit
  2016-06-21 10:47 ` Andy Wingo
  2016-09-03  7:33 ` bug#15228: making open-process public Amirouche Boubekki
@ 2021-06-02  5:45 ` Adriano Peluso
  2 siblings, 0 replies; 7+ messages in thread
From: Adriano Peluso @ 2021-06-02  5:45 UTC (permalink / raw)
  To: 15228

Is this bug still current ?

Can this be closed ?









^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#15228: [PATCH] Close output port of I/O pipes
       [not found] ` <8760sxb74x.fsf@pobox.com>
@ 2016-06-27  8:05   ` Andy Wingo
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2016-06-27  8:05 UTC (permalink / raw)
  To: 15228

[bouncing this back to debbugs]

On Sat 25 Jun 2016 17:49, Andy Wingo <wingo@pobox.com> writes:

> On Sat 25 Jun 2016 15:51, Josep Portella Florit <jpf@primfilat.com> writes:
>
>>> I dunno how much we should push this "processes are a single port"
>>> abstraction.  In many ways for OPEN_BOTH pipes it's easier to deal with
>>> an input and an output port and a PID instead of the pipe abstraction.
>>> WDYT?  We could just expose `open-process' from (ice-9 popen) to start
>>> with.  It would be good to allow other fd's or ports to map to the child
>>> as well, e.g. stderr or any particular port; but I don't know what
>>> interface we should expose.
>>
>> Since patching was inconvenient for me, I eventually used:
>>
>> (use-modules ((ice-9 popen) #:select (open-process)))
>>
>> Which works even though `open-process` is not exported.
>
> Note that this behavior of #:select is a bug.  We won't remove it in
> stable-2.0 but we have removed it in master.
>
>> For me, exporting `open-process` and documenting it would be enough.
>
> Fine with me, many people have asked for this at this point.  I guess
> that's the next step for this bug.
>
>> I also like the Racket interface to processes:
>> <https://docs.racket-lang.org/reference/subprocess.html>
>> (I've mostly used the `process` procedure.)
>
> Duly noted!  The more we steal from Racket, the better Guile will be :)
>
> Andy





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-02  5:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-31  8:29 bug#15228: [PATCH] Close output port of I/O pipes Josep Portella Florit
2016-06-21 10:47 ` Andy Wingo
2016-09-03  7:33 ` bug#15228: making open-process public Amirouche Boubekki
2017-02-28  9:58   ` Andy Wingo
2017-03-05 20:41   ` Amirouche
2021-06-02  5:45 ` bug#15228: can this be closed ? Adriano Peluso
     [not found] <628d9c7d-e7d5-6e55-1361-316629db8b4b@primfilat.com>
     [not found] ` <8760sxb74x.fsf@pobox.com>
2016-06-27  8:05   ` bug#15228: [PATCH] Close output port of I/O pipes Andy Wingo

unofficial mirror of bug-guile@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-bugs/0 guile-bugs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-bugs guile-bugs/ https://yhetil.org/guile-bugs \
		bug-guile@gnu.org
	public-inbox-index guile-bugs

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.bugs
	nntp://news.gmane.io/gmane.lisp.guile.bugs


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git