From 0374398fd14bf587d80d9d31e361e266e69387c8 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 23 May 2009 12:09:06 +0200 Subject: conntrackd: add child process infrastructure This patch adds a simple infrastructure that allows to account the child processes that have been forked. This also includes a callback handler that can be registered that is called once the child process finishes. We can extended this later to include an alarm to limit the maximum lifetime of a forked child process. This is good to ensure that child processes behave timely. Signed-off-by: Pablo Neira Ayuso --- src/sync-mode.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/sync-mode.c') diff --git a/src/sync-mode.c b/src/sync-mode.c index 298fcd2..0d35923 100644 --- a/src/sync-mode.c +++ b/src/sync-mode.c @@ -26,6 +26,7 @@ #include "fds.h" #include "event.h" #include "queue.h" +#include "process.h" #include #include @@ -391,28 +392,28 @@ static int local_handler_sync(int fd, int type, void *data) switch(type) { case DUMP_INTERNAL: - ret = fork(); + ret = fork_process_new(NULL, NULL); if (ret == 0) { cache_dump(STATE_SYNC(internal), fd, NFCT_O_PLAIN); exit(EXIT_SUCCESS); } break; case DUMP_EXTERNAL: - ret = fork(); + ret = fork_process_new(NULL, NULL); if (ret == 0) { cache_dump(STATE_SYNC(external), fd, NFCT_O_PLAIN); exit(EXIT_SUCCESS); } break; case DUMP_INT_XML: - ret = fork(); + ret = fork_process_new(NULL, NULL); if (ret == 0) { cache_dump(STATE_SYNC(internal), fd, NFCT_O_XML); exit(EXIT_SUCCESS); } break; case DUMP_EXT_XML: - ret = fork(); + ret = fork_process_new(NULL, NULL); if (ret == 0) { cache_dump(STATE_SYNC(external), fd, NFCT_O_XML); exit(EXIT_SUCCESS); @@ -421,7 +422,7 @@ static int local_handler_sync(int fd, int type, void *data) case COMMIT: /* delete the reset alarm if any before committing */ del_alarm(&STATE_SYNC(reset_cache_alarm)); - ret = fork(); + ret = fork_process_new(NULL, NULL); if (ret == 0) { dlog(LOG_NOTICE, "committing external cache"); cache_commit(STATE_SYNC(external)); -- cgit v1.2.3