[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] branch main updated: 'system*' can no longer close file
From: |
Ludovic Courtès |
Subject: |
[Guile-commits] branch main updated: 'system*' can no longer close file descriptor 2. |
Date: |
Fri, 05 Aug 2022 08:21:55 -0400 |
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 56b1ea900 'system*' can no longer close file descriptor 2.
56b1ea900 is described below
commit 56b1ea9002d2d3967b597aa0ee7595e815b21f23
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Aug 5 12:35:36 2022 +0200
'system*' can no longer close file descriptor 2.
Fixes <https://bugs.gnu.org/55596>.
Reported by Hugo Nobrega <hugonobrega@ic.ufrj.br>
and Jack Hill <jackhill@jackhill.us>.
* libguile/posix.c (start_child): Close OUT only if it's greater than 2.
* test-suite/tests/posix.test ("system*")["exit code for nonexistent file"]
["https://bugs.gnu.org/55596"]: New tests.
---
libguile/posix.c | 5 +++--
test-suite/tests/posix.test | 16 ++++++++++++++--
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/libguile/posix.c b/libguile/posix.c
index 3ab12b99e..f4ca72d3e 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-2014,2016-2019,2021
+/* Copyright 1995-2014, 2016-2019, 2021-2022
Free Software Foundation, Inc.
This file is part of Guile.
@@ -1371,7 +1371,8 @@ start_child (const char *exec_file, char **exec_argv,
if (err == 1)
err = renumber_file_descriptor (err, err);
do dup2 (out, 1); while (errno == EINTR);
- close (out);
+ if (out > 2)
+ close (out);
}
if (err > 2)
{
diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test
index 1e552d16f..500dbb94a 100644
--- a/test-suite/tests/posix.test
+++ b/test-suite/tests/posix.test
@@ -1,6 +1,6 @@
;;;; posix.test --- Test suite for Guile POSIX functions. -*- scheme -*-
;;;;
-;;;; Copyright 2003-2004,2006-2007,2010,2012,2015,2017-2019,2021
+;;;; Copyright 2003-2004, 2006-2007, 2010, 2012, 2015, 2017-2019, 2021-2022
;;;; Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
@@ -241,7 +241,19 @@
;; `system*' would remain alive after an `execvp' failure.
(let ((me (getpid)))
(and (not (zero? (system* "something-that-does-not-exist")))
- (= me (getpid))))))
+ (= me (getpid)))))
+
+ (pass-if-equal "exit code for nonexistent file"
+ 127 ;aka. EX_NOTFOUND
+ (status:exit-val (system* "something-that-does-not-exist")))
+
+ (pass-if-equal "https://bugs.gnu.org/55596"
+ 127
+ ;; The parameterization below used to cause 'start_child' to close
+ ;; fd 2 in the child process, which in turn would cause it to
+ ;; segfault, leading to a wrong exit code.
+ (parameterize ((current-output-port (current-error-port)))
+ (status:exit-val (system* "something-that-does-not-exist")))))
;;
;; crypt
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] branch main updated: 'system*' can no longer close file descriptor 2.,
Ludovic Courtès <=