* [PATCH] ignore gdb/patch related files @ 2009-11-04 14:26 Mike Frysinger 2009-11-04 14:26 ` [PATCH] tc: remove dlfcn.h from files that dont need it Mike Frysinger 2009-11-04 14:26 ` [PATCH] ifstat/nstat/rtacct: use daemon() Mike Frysinger 0 siblings, 2 replies; 4+ messages in thread From: Mike Frysinger @ 2009-11-04 14:26 UTC (permalink / raw) To: stephen.hemminger, netdev Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- .gitignore | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore index 8199aae..5a3d20f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,12 @@ Config +.gdbinit +.gdb_history *.o *.a *.so +*.gdb *~ +*.diff +*.patch +*.orig +*.rej -- 1.6.5.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] tc: remove dlfcn.h from files that dont need it 2009-11-04 14:26 [PATCH] ignore gdb/patch related files Mike Frysinger @ 2009-11-04 14:26 ` Mike Frysinger 2009-11-04 14:26 ` [PATCH] ifstat/nstat/rtacct: use daemon() Mike Frysinger 1 sibling, 0 replies; 4+ messages in thread From: Mike Frysinger @ 2009-11-04 14:26 UTC (permalink / raw) To: stephen.hemminger, netdev A bunch of source files look like they're copy & pasted from other files, and some include header files that they don't actually need. Since dlfcn has very specific usage (and is a pain on a static-only system), drop it where it isn't really needed. Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- tc/em_cmp.c | 1 - tc/em_meta.c | 1 - tc/em_nbyte.c | 1 - tc/em_u32.c | 1 - tc/m_nat.c | 1 - tc/m_xt.c | 1 - 6 files changed, 0 insertions(+), 6 deletions(-) diff --git a/tc/em_cmp.c b/tc/em_cmp.c index ce72a42..6addce0 100644 --- a/tc/em_cmp.c +++ b/tc/em_cmp.c @@ -18,7 +18,6 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> -#include <dlfcn.h> #include <errno.h> #include "m_ematch.h" diff --git a/tc/em_meta.c b/tc/em_meta.c index ee6034f..033e29f 100644 --- a/tc/em_meta.c +++ b/tc/em_meta.c @@ -18,7 +18,6 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> -#include <dlfcn.h> #include <errno.h> #include "m_ematch.h" diff --git a/tc/em_nbyte.c b/tc/em_nbyte.c index 242c361..87f3e9d 100644 --- a/tc/em_nbyte.c +++ b/tc/em_nbyte.c @@ -18,7 +18,6 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> -#include <dlfcn.h> #include <errno.h> #include "m_ematch.h" diff --git a/tc/em_u32.c b/tc/em_u32.c index 402bea0..21ed70f 100644 --- a/tc/em_u32.c +++ b/tc/em_u32.c @@ -18,7 +18,6 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> -#include <dlfcn.h> #include <errno.h> #include "m_ematch.h" diff --git a/tc/m_nat.c b/tc/m_nat.c index 6e7fd05..01ec032 100644 --- a/tc/m_nat.c +++ b/tc/m_nat.c @@ -19,7 +19,6 @@ #include <netinet/in.h> #include <arpa/inet.h> #include <string.h> -#include <dlfcn.h> #include "utils.h" #include "tc_util.h" #include <linux/tc_act/tc_nat.h> diff --git a/tc/m_xt.c b/tc/m_xt.c index 0fe6189..0c7ec60 100644 --- a/tc/m_xt.c +++ b/tc/m_xt.c @@ -25,7 +25,6 @@ #include "tc_util.h" #include <linux/tc_act/tc_ipt.h> #include <stdio.h> -#include <dlfcn.h> #include <getopt.h> #include <errno.h> #include <string.h> -- 1.6.5.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ifstat/nstat/rtacct: use daemon() 2009-11-04 14:26 [PATCH] ignore gdb/patch related files Mike Frysinger 2009-11-04 14:26 ` [PATCH] tc: remove dlfcn.h from files that dont need it Mike Frysinger @ 2009-11-04 14:26 ` Mike Frysinger 2009-11-06 11:04 ` [PATCH v2] arpd/ifstat/nstat/rtacct: " Mike Frysinger 1 sibling, 1 reply; 4+ messages in thread From: Mike Frysinger @ 2009-11-04 14:26 UTC (permalink / raw) To: stephen.hemminger, netdev A bunch of misc utils basically reimplement the daemon() function (the whole fork/close/chdir/etc...). Rather than do that, use daemon() as that will work under nommu Linux systems that lack fork(). Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- misc/ifstat.c | 8 ++++---- misc/nstat.c | 8 ++++---- misc/rtacct.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/misc/ifstat.c b/misc/ifstat.c index 68dfdee..0ce8c92 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -663,10 +663,10 @@ int main(int argc, char *argv[]) perror("ifstat: listen"); exit(-1); } - if (fork()) - exit(0); - chdir("/"); - close(0); close(1); close(2); setsid(); + if (daemon(0, 0)) { + perror("ifstat: daemon"); + exit(-1); + } signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, sigchild); server_loop(fd); diff --git a/misc/nstat.c b/misc/nstat.c index 80e695f..2e44ed2 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -513,10 +513,10 @@ int main(int argc, char *argv[]) perror("nstat: listen"); exit(-1); } - if (fork()) - exit(0); - chdir("/"); - close(0); close(1); close(2); setsid(); + if (daemon(0, 0)) { + perror("nstat: daemon"); + exit(-1); + } signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, sigchild); server_loop(fd); diff --git a/misc/rtacct.c b/misc/rtacct.c index eb3ea9e..a247dfd 100644 --- a/misc/rtacct.c +++ b/misc/rtacct.c @@ -524,10 +524,10 @@ int main(int argc, char *argv[]) perror("rtacct: listen"); exit(-1); } - if (fork()) - exit(0); - chdir("/"); - close(0); close(1); close(2); setsid(); + if (daemon(0, 0)) { + perror("rtacct: daemon"); + exit(-1); + } signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, sigchild); server_loop(fd); -- 1.6.5.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] arpd/ifstat/nstat/rtacct: use daemon() 2009-11-04 14:26 ` [PATCH] ifstat/nstat/rtacct: use daemon() Mike Frysinger @ 2009-11-06 11:04 ` Mike Frysinger 0 siblings, 0 replies; 4+ messages in thread From: Mike Frysinger @ 2009-11-06 11:04 UTC (permalink / raw) To: stephen.hemminger, netdev A bunch of misc utils basically reimplement the daemon() function (the whole fork/close/chdir/etc...). Rather than do that, use daemon() as that will work under nommu Linux systems that lack fork(). Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- misc/arpd.c | 24 +++--------------------- misc/ifstat.c | 8 ++++---- misc/nstat.c | 8 ++++---- misc/rtacct.c | 8 ++++---- 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/misc/arpd.c b/misc/arpd.c index 71cd082..128c49d 100644 --- a/misc/arpd.c +++ b/misc/arpd.c @@ -775,27 +775,9 @@ int main(int argc, char **argv) load_initial_table(); - if (1) { - int fd; - pid_t pid = fork(); - - if (pid > 0) - _exit(0); - if (pid < 0) { - perror("arpd: fork"); - goto do_abort; - } - - chdir("/"); - fd = open("/dev/null", O_RDWR); - if (fd >= 0) { - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - if (fd > 2) - close(fd); - } - setsid(); + if (daemon(0, 0)) { + perror("arpd: daemon"); + goto do_abort; } openlog("arpd", LOG_PID | LOG_CONS, LOG_DAEMON); diff --git a/misc/ifstat.c b/misc/ifstat.c index 68dfdee..0ce8c92 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -663,10 +663,10 @@ int main(int argc, char *argv[]) perror("ifstat: listen"); exit(-1); } - if (fork()) - exit(0); - chdir("/"); - close(0); close(1); close(2); setsid(); + if (daemon(0, 0)) { + perror("ifstat: daemon"); + exit(-1); + } signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, sigchild); server_loop(fd); diff --git a/misc/nstat.c b/misc/nstat.c index 80e695f..2e44ed2 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -513,10 +513,10 @@ int main(int argc, char *argv[]) perror("nstat: listen"); exit(-1); } - if (fork()) - exit(0); - chdir("/"); - close(0); close(1); close(2); setsid(); + if (daemon(0, 0)) { + perror("nstat: daemon"); + exit(-1); + } signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, sigchild); server_loop(fd); diff --git a/misc/rtacct.c b/misc/rtacct.c index eb3ea9e..a247dfd 100644 --- a/misc/rtacct.c +++ b/misc/rtacct.c @@ -524,10 +524,10 @@ int main(int argc, char *argv[]) perror("rtacct: listen"); exit(-1); } - if (fork()) - exit(0); - chdir("/"); - close(0); close(1); close(2); setsid(); + if (daemon(0, 0)) { + perror("rtacct: daemon"); + exit(-1); + } signal(SIGPIPE, SIG_IGN); signal(SIGCHLD, sigchild); server_loop(fd); -- 1.6.5.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-06 11:03 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-11-04 14:26 [PATCH] ignore gdb/patch related files Mike Frysinger 2009-11-04 14:26 ` [PATCH] tc: remove dlfcn.h from files that dont need it Mike Frysinger 2009-11-04 14:26 ` [PATCH] ifstat/nstat/rtacct: use daemon() Mike Frysinger 2009-11-06 11:04 ` [PATCH v2] arpd/ifstat/nstat/rtacct: " Mike Frysinger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox