* [2.31 COMMITTED] support/shell-container.c: Return 127 if execve fails
@ 2020-03-25 13:35 Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] support/shell-container.c: Add builtin exit Adhemerval Zanella
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2020-03-25 13:35 UTC (permalink / raw)
To: libc-stable
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 5fce0e095bc413f908f472074c2235198cd76bf4)
---
support/shell-container.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/support/shell-container.c b/support/shell-container.c
index 509e0d69b1..0f4568ed0c 100644
--- a/support/shell-container.c
+++ b/support/shell-container.c
@@ -238,7 +238,7 @@ run_command_array (char **argv)
fprintf (stderr, "sh: execing %s failed: %s",
argv[0], strerror (errno));
- exit (1);
+ exit (127);
}
waitpid (pid, &status, 0);
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [2.31 COMMITTED] support/shell-container.c: Add builtin exit
2020-03-25 13:35 [2.31 COMMITTED] support/shell-container.c: Return 127 if execve fails Adhemerval Zanella
@ 2020-03-25 13:35 ` Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] support/shell-container.c: Add builtin kill Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] stdlib: Move tst-system to tests-container Adhemerval Zanella
2 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2020-03-25 13:35 UTC (permalink / raw)
To: libc-stable
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 5a5a3a3234bc220a5192d620e0cbc5360da46f14)
---
support/shell-container.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/support/shell-container.c b/support/shell-container.c
index 0f4568ed0c..6540f8ac47 100644
--- a/support/shell-container.c
+++ b/support/shell-container.c
@@ -135,6 +135,18 @@ copy_func (char **argv)
}
+/* Emulate the 'exit' builtin. The exit value is optional. */
+static int
+exit_func (char **argv)
+{
+ int exit_val = 0;
+
+ if (argv[0] != 0)
+ exit_val = atoi (argv[0]) & 0xff;
+ exit (exit_val);
+ return 0;
+}
+
/* This is a list of all the built-in commands we understand. */
static struct {
const char *name;
@@ -143,6 +155,7 @@ static struct {
{ "true", true_func },
{ "echo", echo_func },
{ "cp", copy_func },
+ { "exit", exit_func },
{ NULL, NULL }
};
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [2.31 COMMITTED] support/shell-container.c: Add builtin kill
2020-03-25 13:35 [2.31 COMMITTED] support/shell-container.c: Return 127 if execve fails Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] support/shell-container.c: Add builtin exit Adhemerval Zanella
@ 2020-03-25 13:35 ` Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] stdlib: Move tst-system to tests-container Adhemerval Zanella
2 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2020-03-25 13:35 UTC (permalink / raw)
To: libc-stable
No options supported.
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 1c17100c43c0913ec94f3bcc966bf3792236c690)
---
support/shell-container.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/support/shell-container.c b/support/shell-container.c
index 6540f8ac47..201536d24e 100644
--- a/support/shell-container.c
+++ b/support/shell-container.c
@@ -147,6 +147,25 @@ exit_func (char **argv)
return 0;
}
+/* Emulate the "/bin/kill" command. Options are ignored. */
+static int
+kill_func (char **argv)
+{
+ int signum = SIGTERM;
+ int i;
+
+ for (i = 0; argv[i]; i++)
+ {
+ pid_t pid;
+ if (strcmp (argv[i], "$$") == 0)
+ pid = getpid ();
+ else
+ pid = atoi (argv[i]);
+ kill (pid, signum);
+ }
+ return 0;
+}
+
/* This is a list of all the built-in commands we understand. */
static struct {
const char *name;
@@ -156,6 +175,7 @@ static struct {
{ "echo", echo_func },
{ "cp", copy_func },
{ "exit", exit_func },
+ { "kill", kill_func },
{ NULL, NULL }
};
@@ -264,6 +284,11 @@ run_command_array (char **argv)
if (rv)
exit (rv);
}
+ else if (WIFSIGNALED (status))
+ {
+ int sig = WTERMSIG (status);
+ raise (sig);
+ }
else
exit (1);
}
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [2.31 COMMITTED] stdlib: Move tst-system to tests-container
2020-03-25 13:35 [2.31 COMMITTED] support/shell-container.c: Return 127 if execve fails Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] support/shell-container.c: Add builtin exit Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] support/shell-container.c: Add builtin kill Adhemerval Zanella
@ 2020-03-25 13:35 ` Adhemerval Zanella
2 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2020-03-25 13:35 UTC (permalink / raw)
To: libc-stable
Fix some issues with different shell and error messages.
Checked on x86_64-linux-gnu and i686-linux-gnu.
(cherry picked from commit 4eda036f5b897fa8bc20ddd2099b5a6ed4239dc9)
---
stdlib/Makefile | 3 ++-
stdlib/tst-system.c | 10 ++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 45214b59e4..4615f6dfe7 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -70,7 +70,7 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
test-canon test-canon2 tst-strtoll tst-environ \
tst-xpg-basename tst-random tst-random2 tst-bsearch \
tst-limits tst-rand48 bug-strtod tst-setcontext \
- tst-setcontext2 test-a64l tst-qsort tst-system testmb2 \
+ tst-setcontext2 test-a64l tst-qsort testmb2 \
bug-strtod2 tst-atof1 tst-atof2 tst-strtod2 \
tst-rand48-2 tst-makecontext tst-strtod5 \
tst-qsort2 tst-makecontext2 tst-strtod6 tst-unsetenv1 \
@@ -92,6 +92,7 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
tests-internal := tst-strtod1i tst-strtod3 tst-strtod4 tst-strtod5i \
tst-tls-atexit tst-tls-atexit-nodelete
tests-static := tst-secure-getenv
+tests-container := tst-system
ifeq ($(build-hardcoded-path-in-tests),yes)
tests += tst-empty-env
diff --git a/stdlib/tst-system.c b/stdlib/tst-system.c
index c8c1811349..eddea33f4c 100644
--- a/stdlib/tst-system.c
+++ b/stdlib/tst-system.c
@@ -88,7 +88,8 @@ do_test (void)
});
support_capture_subprocess_check (&result, "system", 0, sc_allow_stderr);
- char *returnerr = xasprintf ("%s: 1: %s: not found\n",
+ char *returnerr = xasprintf ("%s: execing %s failed: "
+ "No such file or directory",
basename(_PATH_BSHELL), cmd);
TEST_COMPARE_STRING (result.err.buffer, returnerr);
free (returnerr);
@@ -106,7 +107,8 @@ do_test (void)
});
support_capture_subprocess_check (&result, "system", 0, sc_allow_stderr);
- char *returnerr = xasprintf ("%s: 1: %s: File name too long\n",
+ char *returnerr = xasprintf ("%s: execing %s failed: "
+ "File name too long",
basename(_PATH_BSHELL), cmd);
TEST_COMPARE_STRING (result.err.buffer, returnerr);
free (returnerr);
@@ -116,7 +118,7 @@ do_test (void)
struct support_capture_subprocess result;
result = support_capture_subprocess (call_system,
&(struct args) {
- "kill -USR1 $$", 0, SIGUSR1
+ "kill $$", 0, SIGTERM
});
support_capture_subprocess_check (&result, "system", 0, sc_allow_none);
}
@@ -136,7 +138,7 @@ do_test (void)
support_capture_subprocess_check (&result, "system", 0, sc_allow_none);
}
- TEST_COMPARE (system (":"), 0);
+ TEST_COMPARE (system (""), 0);
return 0;
}
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-25 13:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 13:35 [2.31 COMMITTED] support/shell-container.c: Return 127 if execve fails Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] support/shell-container.c: Add builtin exit Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] support/shell-container.c: Add builtin kill Adhemerval Zanella
2020-03-25 13:35 ` [2.31 COMMITTED] stdlib: Move tst-system to tests-container Adhemerval Zanella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).