aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-29 16:00:52 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-29 16:00:52 +0000
commit02f12f53e8d7fa92dbf4e7c9c5cb011e7922d74c (patch)
treedf7f4f0839821ecf947cc9a268086de2a26811cc
parentcae11b51aac9f52d35f2446a26acafbe7be8e9bd (diff)
downloadbusybox-02f12f53e8d7fa92dbf4e7c9c5cb011e7922d74c.tar.gz
inetd: small shrink for NOMMU case
function old new delta cat_args - 8 +8 echo_stream 64 63 -1 discard_stream 64 63 -1 static.args 32 12 -20 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 8/-22) Total: -14 bytes
-rw-r--r--networking/inetd.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/networking/inetd.c b/networking/inetd.c
index eb19d1630..d71a1159c 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1413,6 +1413,10 @@ int inetd_main(int argc ATTRIBUTE_UNUSED, char **argv)
} /* for (;;) */
}
+#if !BB_MMU
+static const char *const cat_args[] = { "cat", NULL };
+#endif
+
/*
* Internet services provided internally by inetd:
*/
@@ -1430,13 +1434,13 @@ static void echo_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
}
#else
/* We are after vfork here! */
- static const char *const args[] = { "cat", NULL };
- /* move network socket to stdin */
+ /* move network socket to stdin/stdout */
xmove_fd(s, STDIN_FILENO);
xdup2(STDIN_FILENO, STDOUT_FILENO);
/* no error messages please... */
- xmove_fd(xopen("/dev/null", O_WRONLY), STDERR_FILENO);
- BB_EXECVP("cat", (char**)args);
+ close(STDERR_FILENO);
+ xopen("/dev/null", O_WRONLY);
+ BB_EXECVP("cat", (char**)cat_args);
/* on failure we return to main, which does exit(1) */
#endif
}
@@ -1467,13 +1471,14 @@ static void discard_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
continue;
#else
/* We are after vfork here! */
- static const char *const args[] = { "dd", "of=/dev/null", NULL };
/* move network socket to stdin */
xmove_fd(s, STDIN_FILENO);
- xdup2(STDIN_FILENO, STDOUT_FILENO);
- /* no error messages */
- xmove_fd(xopen("/dev/null", O_WRONLY), STDERR_FILENO);
- BB_EXECVP("dd", (char**)args);
+ /* discard output */
+ close(STDOUT_FILENO);
+ xopen("/dev/null", O_WRONLY);
+ /* no error messages please... */
+ xdup2(STDOUT_FILENO, STDERR_FILENO);
+ BB_EXECVP("cat", (char**)cat_args);
/* on failure we return to main, which does exit(1) */
#endif
}