guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] branch main updated: 'spawn' ensures it is passed open f


From: Ludovic Courtès
Subject: [Guile-commits] branch main updated: 'spawn' ensures it is passed open file ports.
Date: Thu, 26 Jan 2023 03:45:05 -0500

This is an automated email from the git hooks/post-receive script.

civodul pushed a commit to branch main
in repository guile.

The following commit(s) were added to refs/heads/main by this push:
     new 5b42f8c15 'spawn' ensures it is passed open file ports.
5b42f8c15 is described below

commit 5b42f8c154906584455a4989038406c88b723cb0
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Thu Jan 26 09:42:46 2023 +0100

    'spawn' ensures it is passed open file ports.
    
    Fixes <https://bugs.gnu.org/61073>.
    
    * libguile/posix.c (FDES_FROM_PORT_OR_INTEGER): When OBJ is not an
    integer, use 'SCM_VALIDATE_OPFPORT' before using 'SCM_FPORT_FDES'.
    * test-suite/tests/posix.test ("spawn")["non-file port argument"]: New
    test.
---
 libguile/posix.c            | 18 +++++++++++++-----
 test-suite/tests/posix.test |  5 +++++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index 0b1fe2637..3a8be94e4 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1486,12 +1486,20 @@ SCM_DEFINE (scm_spawn_process, "spawn", 2, 0, 1,
   if (SCM_UNBNDP (err_scm))
     err_scm = scm_current_error_port ();
 
-#define FDES_FROM_PORT_OR_INTEGER(obj)                                  \
-  (scm_is_integer (obj) ? scm_to_int (obj) : SCM_FPORT_FDES (obj))
+#define FDES_FROM_PORT_OR_INTEGER(fd, obj, pos) \
+  {                                             \
+    if (scm_is_integer (obj))                   \
+      fd = scm_to_int (obj);                    \
+    else                                        \
+      {                                         \
+        SCM_VALIDATE_OPFPORT (pos, obj);        \
+        fd = SCM_FPORT_FDES (obj);              \
+      }                                         \
+  }
 
-  in  = FDES_FROM_PORT_OR_INTEGER (in_scm);
-  out = FDES_FROM_PORT_OR_INTEGER (out_scm);
-  err = FDES_FROM_PORT_OR_INTEGER (err_scm);
+  FDES_FROM_PORT_OR_INTEGER (in, in_scm, 3);
+  FDES_FROM_PORT_OR_INTEGER (out, out_scm, 4);
+  FDES_FROM_PORT_OR_INTEGER (err, err_scm, 5);
 
 #undef FDES_FROM_PORT_OR_INTEGER
 
diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test
index bd3e6218c..f20e04453 100644
--- a/test-suite/tests/posix.test
+++ b/test-suite/tests/posix.test
@@ -386,6 +386,11 @@
       0
     (cdr (waitpid (spawn "true" '("true")))))
 
+  (pass-if-exception "non-file port argument" ;<https://bugs.gnu.org/61073>
+      exception:wrong-type-arg
+    (spawn "true" '("true")
+           #:error (%make-void-port "w")))
+
   (pass-if-equal "uname with stdout redirect"
       (list 0                                     ;exit value
             (string-append (utsname:sysname (uname)) " "



reply via email to

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