summaryrefslogtreecommitdiff
path: root/src/sync-mode.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-05-23 12:09:06 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2009-05-23 12:09:06 +0200
commit0374398fd14bf587d80d9d31e361e266e69387c8 (patch)
tree2984629205760d10660fa43c237073e555ce03c8 /src/sync-mode.c
parent91bf01ee31b754bb17f612ee13685ef0ffe9baa8 (diff)
downloadconntrack-tools-0374398fd14bf587d80d9d31e361e266e69387c8.tar.gz
conntrack-tools-0374398fd14bf587d80d9d31e361e266e69387c8.zip
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 <pablo@netfilter.org>
Diffstat (limited to 'src/sync-mode.c')
-rw-r--r--src/sync-mode.c11
1 files changed, 6 insertions, 5 deletions
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 <errno.h>
#include <unistd.h>
@@ -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));