From 42dda89dcb0407f6799dbfd0b9dab1529666ad51 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 11 Dec 2020 15:23:05 -0300 Subject: posix: Fix return value of system if shell can not be executed [BZ #27053] POSIX states that system returned code for failure to execute the shell shall be as if the shell had terminated using _exit(127). This behaviour was removed with 5fb7fc96350575. Checked on x86_64-linux-gnu. --- stdlib/tst-system.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'stdlib/tst-system.c') diff --git a/stdlib/tst-system.c b/stdlib/tst-system.c index 95a2615..178808e 100644 --- a/stdlib/tst-system.c +++ b/stdlib/tst-system.c @@ -26,6 +26,7 @@ #include #include #include +#include static char *tmpdir; static long int namemax; @@ -138,6 +139,22 @@ do_test (void) support_capture_subprocess_check (&result, "system", 0, sc_allow_none); } + { + struct stat64 st; + xstat (_PATH_BSHELL, &st); + mode_t mode = st.st_mode; + xchmod (_PATH_BSHELL, mode & ~(S_IXUSR | S_IXGRP | S_IXOTH)); + + struct support_capture_subprocess result; + result = support_capture_subprocess (call_system, + &(struct args) { + "exit 1", 127, 0 + }); + support_capture_subprocess_check (&result, "system", 0, sc_allow_none); + + xchmod (_PATH_BSHELL, st.st_mode); + } + TEST_COMPARE (system (""), 0); return 0; -- cgit v1.1