projects/guix·blob java-team · refs

67 lines · 2.2 KiB

1We want to allow builds in chroots that lack /bin/sh. Thus, system(3)
2and popen(3) need to be tweaked to use the right shell. For the bootstrap
3glibc, we just use whatever `sh' can be found in $PATH. The final glibc
4instead uses the hard-coded absolute file name of `bash'.
5
6In addition, status should be initialized to 0 and not -1.
7
8diff --git a/libio/iopopen.c b/libio/iopopen.c
9index 4cc405f2de..8842c989c8 100644
10--- a/libio/iopopen.c
11+++ b/libio/iopopen.c
12@@ -86,7 +86,7 @@ spawn_process (posix_spawn_file_actions_t *fa, FILE *fp, const char *command,
13 }
14 }
15
16- err = __posix_spawn (&((_IO_proc_file *) fp)->pid, _PATH_BSHELL, fa, 0,
17+ err = __posix_spawnp (&((_IO_proc_file *) fp)->pid, "sh", fa, 0,
18 (char *const[]){ (char*) "sh", (char*) "-c", (char*) "--",
19 (char *) command, NULL }, __environ);
20 if (err != 0)
21diff --git a/sysdeps/posix/system.c b/sysdeps/posix/system.c
22index 488b95163b..56b8a028ae 100644
23--- a/sysdeps/posix/system.c
24+++ b/sysdeps/posix/system.c
25@@ -100,7 +100,7 @@ cancel_handler (void *arg)
26 static int
27 do_system (const char *line)
28 {
29- int status = -1;
30+ int status = 0;
31 int ret;
32 pid_t pid;
33 struct sigaction sa;
34@@ -144,7 +144,7 @@ do_system (const char *line)
35 __posix_spawnattr_setflags (&spawn_attr,
36 POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK);
37
38- ret = __posix_spawn (&pid, SHELL_PATH, 0, &spawn_attr,
39+ ret = __posix_spawnp (&pid, SHELL_NAME, 0, &spawn_attr,
40 (char *const[]){ (char *) SHELL_NAME,
41 (char *) "-c",
42 (char *) "--",
43diff --git a/include/spawn.h b/include/spawn.h
44index 4a0b1849da..9e47f74391 100644
45--- a/include/spawn.h
46+++ b/include/spawn.h
47@@ -5,6 +5,9 @@
48 __typeof (posix_spawn) __posix_spawn;
49 libc_hidden_proto (__posix_spawn)
50
51+__typeof (posix_spawnp) __posix_spawnp;
52+libc_hidden_proto (__posix_spawnp)
53+
54 __typeof (posix_spawn_file_actions_addclose)
55 __posix_spawn_file_actions_addclose attribute_hidden;
56
57--- a/posix/spawnp.c
58+++ b/posix/spawnp.c
59@@ -31,6 +31,7 @@ __posix_spawnp (pid_t *pid, const char *file,
60 SPAWN_XFLAGS_USE_PATH);
61 }
62 versioned_symbol (libc, __posix_spawnp, posix_spawnp, GLIBC_2_15);
63+libc_hidden_def (__posix_spawnp)
64
65
66 #if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15)
67