diff options
author | Ludovic Courtès <ludo@gnu.org> | 2023-01-26 09:42:46 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2023-01-26 09:42:46 +0100 |
commit | 5b42f8c154906584455a4989038406c88b723cb0 (patch) | |
tree | 888bdb38f3d2d67faf6c970647bff519e86524d1 /libguile/posix.c | |
parent | 35566ea585d6ebb0e97a83956de6a39ae2a0c2d5 (diff) | |
download | guile-5b42f8c154906584455a4989038406c88b723cb0.tar.gz |
'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.
Diffstat (limited to 'libguile/posix.c')
-rw-r--r-- | libguile/posix.c | 18 |
1 files changed, 13 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 |