diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/process.c | 25 | ||||
-rw-r--r-- | src/run.c | 3 |
3 files changed, 32 insertions, 0 deletions
@@ -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); +} @@ -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)) |