1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-01 23:30:28 +02:00

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
This commit is contained in:
Michael Gran 2018-04-19 13:21:47 -07:00
parent 98f4024e0a
commit b2a50874bb
2 changed files with 17 additions and 9 deletions

View file

@ -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");

View file

@ -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)))))