summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c4
-rw-r--r--src/process.c25
-rw-r--r--src/run.c3
3 files changed, 32 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 7507ae5..6b320d1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -214,6 +214,10 @@ int main(int argc, char *argv[])
strlen(argv[i+1])) == 0) {
action = STATS_QUEUE;
i++;
+ } else if (strncmp(argv[i+1], "process",
+ strlen(argv[i+1])) == 0) {
+ action = STATS_PROCESS;
+ i++;
} else {
fprintf(stderr, "ERROR: unknown "
"parameter `%s' for "
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);
+}
diff --git a/src/run.c b/src/run.c
index fe81d54..95d51a2 100644
--- a/src/run.c
+++ b/src/run.c
@@ -216,6 +216,9 @@ void local_handler(int fd, void *data)
case STATS_RUNTIME:
dump_stats_runtime(fd);
return;
+ case STATS_PROCESS:
+ fork_process_dump(fd);
+ return;
}
if (!STATE(mode)->local(fd, type, data))