diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-06-11 20:33:14 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-06-11 20:33:14 +0200 |
commit | 8fc9066ee62d17cdb76bc064c945da3bb0d2e2a3 (patch) | |
tree | bfde54b1611023e42a918bbd1911b874a6d0bff2 /src/process.c | |
parent | 9163f4673d919658c94f9de4ca32a2e9dacce2fd (diff) | |
download | conntrack-tools-8fc9066ee62d17cdb76bc064c945da3bb0d2e2a3.tar.gz conntrack-tools-8fc9066ee62d17cdb76bc064c945da3bb0d2e2a3.zip |
conntrackd: add support to display statistics on existing child processes
This patch adds the ability to dump the list of existing child
processes. In general, it would be hard to display one since
child processes are generally forked for very specific tasks,
like commit and flush operations, and they have very limited
lifetime. However, this can be handy for debugging problems.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/process.c')
-rw-r--r-- | src/process.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/process.c b/src/process.c index c378f7a..9b9734c 100644 --- a/src/process.c +++ b/src/process.c @@ -76,3 +76,28 @@ int fork_process_delete(int pid) } return 0; } + +static const char *process_type_to_name[CTD_PROC_MAX] = { + [CTD_PROC_ANY] = "any", + [CTD_PROC_FLUSH] = "flush", + [CTD_PROC_COMMIT] = "commit", +}; + +void fork_process_dump(int fd) +{ + struct child_process *this; + char buf[4096]; + int size = 0; + + sigprocmask(SIG_BLOCK, &STATE(block), NULL); + list_for_each_entry(this, &process_list, head) { + size += snprintf(buf+size, sizeof(buf), + "PID=%u type=%s\n", + this->pid, + this->type < CTD_PROC_MAX ? + process_type_to_name[this->type] : "unknown"); + } + sigprocmask(SIG_UNBLOCK, &STATE(block), NULL); + + send(fd, buf, size, 0); +} |