aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/libunarchive/open_transformer.c9
-rw-r--r--include/libbb.h3
-rw-r--r--libbb/vfork_daemon_rexec.c4
-rw-r--r--libbb/xvfork.c10
-rw-r--r--networking/inetd.c2
-rw-r--r--shell/hush.c8
-rw-r--r--util-linux/mount.c1
7 files changed, 19 insertions, 18 deletions
diff --git a/archival/libunarchive/open_transformer.c b/archival/libunarchive/open_transformer.c
index 16ca6a59c..0738e3db1 100644
--- a/archival/libunarchive/open_transformer.c
+++ b/archival/libunarchive/open_transformer.c
@@ -20,14 +20,7 @@ int FAST_FUNC open_transformer(int src_fd,
20 20
21 xpiped_pair(fd_pipe); 21 xpiped_pair(fd_pipe);
22 22
23#if BB_MMU 23 pid = BB_MMU ? xfork() : xvfork();
24 pid = fork();
25 if (pid == -1)
26 bb_perror_msg_and_die("can't fork");
27#else
28 pid = xvfork();
29#endif
30
31 if (pid == 0) { 24 if (pid == 0) {
32 /* child process */ 25 /* child process */
33 close(fd_pipe.rd); /* We don't want to read from the parent */ 26 close(fd_pipe.rd); /* We don't want to read from the parent */
diff --git a/include/libbb.h b/include/libbb.h
index 33e465cf4..67eef6dbb 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -719,6 +719,9 @@ int bb_execvp(const char *file, char *const argv[]) FAST_FUNC;
719#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__) 719#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__)
720#endif 720#endif
721 721
722#if BB_MMU
723pid_t xfork(void) FAST_FUNC;
724#endif
722pid_t xvfork(void) FAST_FUNC; 725pid_t xvfork(void) FAST_FUNC;
723 726
724/* NOMMU friendy fork+exec */ 727/* NOMMU friendy fork+exec */
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index 9baa813a1..989e9b841 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -238,9 +238,7 @@ void FAST_FUNC forkexit_or_rexec(char **argv)
238void FAST_FUNC forkexit_or_rexec(void) 238void FAST_FUNC forkexit_or_rexec(void)
239{ 239{
240 pid_t pid; 240 pid_t pid;
241 pid = fork(); 241 pid = xfork();
242 if (pid < 0) /* wtf? */
243 bb_perror_msg_and_die("fork");
244 if (pid) /* parent */ 242 if (pid) /* parent */
245 exit(EXIT_SUCCESS); 243 exit(EXIT_SUCCESS);
246 /* child */ 244 /* child */
diff --git a/libbb/xvfork.c b/libbb/xvfork.c
index a74b49f48..3fbd0c1ed 100644
--- a/libbb/xvfork.c
+++ b/libbb/xvfork.c
@@ -16,3 +16,13 @@ pid_t FAST_FUNC xvfork(void)
16 bb_perror_msg_and_die("vfork"); 16 bb_perror_msg_and_die("vfork");
17 return pid; 17 return pid;
18} 18}
19
20#if BB_MMU
21pid_t FAST_FUNC xfork(void)
22{
23 pid_t pid = fork();
24 if (pid < 0)
25 bb_perror_msg_and_die("vfork" + 1);
26 return pid;
27}
28#endif
diff --git a/networking/inetd.c b/networking/inetd.c
index 08c09953b..0028078db 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1303,7 +1303,7 @@ int inetd_main(int argc ATTRIBUTE_UNUSED, char **argv)
1303 pid = vfork(); 1303 pid = vfork();
1304 1304
1305 if (pid < 0) { /* fork error */ 1305 if (pid < 0) { /* fork error */
1306 bb_perror_msg("fork"); 1306 bb_perror_msg(BB_MMU ? "vfork" + 1 : "vfork");
1307 sleep(1); 1307 sleep(1);
1308 restore_sigmask(&omask); 1308 restore_sigmask(&omask);
1309 maybe_close(accepted_fd); 1309 maybe_close(accepted_fd);
diff --git a/shell/hush.c b/shell/hush.c
index 59d8f3f99..27fab0d1b 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1902,7 +1902,7 @@ static int run_pipe(struct pipe *pi)
1902#endif 1902#endif
1903 if (child->pid < 0) { /* [v]fork failed */ 1903 if (child->pid < 0) { /* [v]fork failed */
1904 /* Clearly indicate, was it fork or vfork */ 1904 /* Clearly indicate, was it fork or vfork */
1905 bb_perror_msg(BB_MMU ? "fork" : "vfork"); 1905 bb_perror_msg(BB_MMU ? "vfork" + 1 : "vfork");
1906 } else { 1906 } else {
1907 pi->alive_progs++; 1907 pi->alive_progs++;
1908#if ENABLE_HUSH_JOB 1908#if ENABLE_HUSH_JOB
@@ -3096,11 +3096,7 @@ static FILE *generate_stream_from_list(struct pipe *head)
3096 * huge=`cat TESTFILE` # will block here forever 3096 * huge=`cat TESTFILE` # will block here forever
3097 * echo OK 3097 * echo OK
3098 */ 3098 */
3099 pid = BB_MMU ? fork() : xvfork(); 3099 pid = BB_MMU ? xfork() : xvfork();
3100#if BB_MMU
3101 if (pid < 0)
3102 bb_perror_msg_and_die("fork");
3103#endif
3104 if (pid == 0) { /* child */ 3100 if (pid == 0) { /* child */
3105 if (ENABLE_HUSH_JOB) 3101 if (ENABLE_HUSH_JOB)
3106 die_sleep = 0; /* let nofork's xfuncs die */ 3102 die_sleep = 0; /* let nofork's xfuncs die */
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 3b77af728..664d24fd8 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -890,6 +890,7 @@ get_mountport(struct pmap *pm_mnt,
890} 890}
891 891
892#if BB_MMU 892#if BB_MMU
893/* Unlike bb_daemonize(), parent does NOT exit here, but returns 0 */
893static int daemonize(void) 894static int daemonize(void)
894{ 895{
895 int fd; 896 int fd;