svn commit: trunk/busybox: archival/libunarchive include libbb netw etc...
vda at busybox.net
vda at busybox.net
Tue Jul 1 04:11:24 PDT 2008
Author: vda
Date: 2008-07-01 04:11:24 -0700 (Tue, 01 Jul 2008)
New Revision: 22584
Log:
*: introduce and use xfork()
function old new delta
xfork - 20 +20
msh_main 1377 1380 +3
mod_process 455 446 -9
forkexit_or_rexec 30 17 -13
expand_variables 1434 1421 -13
open_transformer 91 76 -15
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/4 up/down: 23/-50) Total: -27 bytes
Modified:
trunk/busybox/archival/libunarchive/open_transformer.c
trunk/busybox/include/libbb.h
trunk/busybox/libbb/vfork_daemon_rexec.c
trunk/busybox/libbb/xvfork.c
trunk/busybox/networking/inetd.c
trunk/busybox/shell/hush.c
trunk/busybox/util-linux/mount.c
Changeset:
Modified: trunk/busybox/archival/libunarchive/open_transformer.c
===================================================================
--- trunk/busybox/archival/libunarchive/open_transformer.c 2008-07-01 10:55:45 UTC (rev 22583)
+++ trunk/busybox/archival/libunarchive/open_transformer.c 2008-07-01 11:11:24 UTC (rev 22584)
@@ -20,14 +20,7 @@
xpiped_pair(fd_pipe);
-#if BB_MMU
- pid = fork();
- if (pid == -1)
- bb_perror_msg_and_die("can't fork");
-#else
- pid = xvfork();
-#endif
-
+ pid = BB_MMU ? xfork() : xvfork();
if (pid == 0) {
/* child process */
close(fd_pipe.rd); /* We don't want to read from the parent */
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h 2008-07-01 10:55:45 UTC (rev 22583)
+++ trunk/busybox/include/libbb.h 2008-07-01 11:11:24 UTC (rev 22584)
@@ -719,6 +719,9 @@
#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__)
#endif
+#if BB_MMU
+pid_t xfork(void) FAST_FUNC;
+#endif
pid_t xvfork(void) FAST_FUNC;
/* NOMMU friendy fork+exec */
Modified: trunk/busybox/libbb/vfork_daemon_rexec.c
===================================================================
--- trunk/busybox/libbb/vfork_daemon_rexec.c 2008-07-01 10:55:45 UTC (rev 22583)
+++ trunk/busybox/libbb/vfork_daemon_rexec.c 2008-07-01 11:11:24 UTC (rev 22584)
@@ -238,9 +238,7 @@
void FAST_FUNC forkexit_or_rexec(void)
{
pid_t pid;
- pid = fork();
- if (pid < 0) /* wtf? */
- bb_perror_msg_and_die("fork");
+ pid = xfork();
if (pid) /* parent */
exit(EXIT_SUCCESS);
/* child */
Modified: trunk/busybox/libbb/xvfork.c
===================================================================
--- trunk/busybox/libbb/xvfork.c 2008-07-01 10:55:45 UTC (rev 22583)
+++ trunk/busybox/libbb/xvfork.c 2008-07-01 11:11:24 UTC (rev 22584)
@@ -16,3 +16,13 @@
bb_perror_msg_and_die("vfork");
return pid;
}
+
+#if BB_MMU
+pid_t FAST_FUNC xfork(void)
+{
+ pid_t pid = fork();
+ if (pid < 0)
+ bb_perror_msg_and_die("vfork" + 1);
+ return pid;
+}
+#endif
Modified: trunk/busybox/networking/inetd.c
===================================================================
--- trunk/busybox/networking/inetd.c 2008-07-01 10:55:45 UTC (rev 22583)
+++ trunk/busybox/networking/inetd.c 2008-07-01 11:11:24 UTC (rev 22584)
@@ -1303,7 +1303,7 @@
pid = vfork();
if (pid < 0) { /* fork error */
- bb_perror_msg("fork");
+ bb_perror_msg(BB_MMU ? "vfork" + 1 : "vfork");
sleep(1);
restore_sigmask(&omask);
maybe_close(accepted_fd);
Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c 2008-07-01 10:55:45 UTC (rev 22583)
+++ trunk/busybox/shell/hush.c 2008-07-01 11:11:24 UTC (rev 22584)
@@ -1902,7 +1902,7 @@
#endif
if (child->pid < 0) { /* [v]fork failed */
/* Clearly indicate, was it fork or vfork */
- bb_perror_msg(BB_MMU ? "fork" : "vfork");
+ bb_perror_msg(BB_MMU ? "vfork" + 1 : "vfork");
} else {
pi->alive_progs++;
#if ENABLE_HUSH_JOB
@@ -3096,11 +3096,7 @@
* huge=`cat TESTFILE` # will block here forever
* echo OK
*/
- pid = BB_MMU ? fork() : xvfork();
-#if BB_MMU
- if (pid < 0)
- bb_perror_msg_and_die("fork");
-#endif
+ pid = BB_MMU ? xfork() : xvfork();
if (pid == 0) { /* child */
if (ENABLE_HUSH_JOB)
die_sleep = 0; /* let nofork's xfuncs die */
Modified: trunk/busybox/util-linux/mount.c
===================================================================
--- trunk/busybox/util-linux/mount.c 2008-07-01 10:55:45 UTC (rev 22583)
+++ trunk/busybox/util-linux/mount.c 2008-07-01 11:11:24 UTC (rev 22584)
@@ -890,6 +890,7 @@
}
#if BB_MMU
+/* Unlike bb_daemonize(), parent does NOT exit here, but returns 0 */
static int daemonize(void)
{
int fd;
More information about the busybox-cvs
mailing list