[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/03: In win32, system* shouldn't launch shell when com
From: |
Mike Gran |
Subject: |
[Guile-commits] 01/03: In win32, system* shouldn't launch shell when command not found |
Date: |
Thu, 19 Apr 2018 16:25:47 -0400 (EDT) |
mike121 pushed a commit to branch wip-mingw-guile-2.2
in repository guile.
commit b2a50874bb64168a2e56bc377c77a26f41fbd217
Author: Michael Gran <address@hidden>
Date: Thu Apr 19 13:21:47 2018 -0700
In win32, system* shouldn't launch shell when command not found
When system* was called to execute a script/excutable without args, if
that did not exist, it would launch an interactive session. Now it fails
with an error.
* libguile/posix-w32.c (start_child): return when cmd not found
* test-suite/tests/posix.test (system*): system* test should handle errors
---
libguile/posix-w32.c | 9 ++++++---
test-suite/tests/posix.test | 17 +++++++++++------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/libguile/posix-w32.c b/libguile/posix-w32.c
index 1f00ec1..6a483c4 100644
--- a/libguile/posix-w32.c
+++ b/libguile/posix-w32.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2006, 2008, 2016 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006, 2008, 2016, 2018 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
@@ -740,8 +740,11 @@ start_child (const char *exec_file, char **argv,
CloseHandle (herr);
CloseHandle (pi.hThread);
- /* Posix requires to call the shell if execvp fails to invoke EXEC_FILE. */
- if (errno_save == ENOEXEC || errno_save == ENOENT)
+ /* Posix requires to call the shell if execvp fails to invoke EXEC_FILE.
+ * But if there are no arguments, this would just open an interactive
+ * cmd.exe shell, so return in that case. */
+ if ((errno_save == ENOEXEC || errno_save == ENOENT)
+ && (argv[0] != NULL && argv[1] != NULL)
{
const char *shell = getenv ("ComSpec");
diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test
index fe130e2..d8975f0 100644
--- a/test-suite/tests/posix.test
+++ b/test-suite/tests/posix.test
@@ -235,8 +235,9 @@
;; With Guile up to 2.0.7 included, the child process launched by
;; `system*' would remain alive after an `execvp' failure.
(let ((me (getpid)))
- (and (not (zero? (system* "something-that-does-not-exist")))
- (= me (getpid))))))
+ (and
+ (not (equal? 0 (false-if-exception (system*
"something-that-does-not-exist"))))
+ (= me (getpid))))))
;;
;; crypt
@@ -245,12 +246,16 @@
(with-test-prefix "crypt"
(pass-if "basic usage"
- (string? (crypt "pass" "abcdefg")))
+ (if (not (defined? 'crypt))
+ (throw 'unsupported)
+ (string? (crypt "pass" "abcdefg"))))
(pass-if-exception "glibc EINVAL" exception:system-error
;; This used to deadlock while trying to throw to 'system-error'.
;; This test uses the special interpretation of the salt that glibc
;; does; specifically, we pass a syntactically invalid salt here.
- (if (string-contains %host-type "-gnu")
- (crypt "pass" "$X$abc") ;EINVAL
- (throw 'unresolved))))
+ (if (not (defined? 'crypt))
+ (throw 'unsupported)
+ (if (string-contains %host-type "-gnu")
+ (crypt "pass" "$X$abc") ;EINVAL
+ (throw 'unresolved)))))