From: Nils Carlson Date: Tue, 29 Mar 2011 13:15:44 +0000 (+0200) Subject: Add list-pids command to ustctl v2 X-Git-Tag: v1.9.1~409 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=dc6c486b9ac1c9db99050f9d9d1919f9cb651027;p=lttng-ust.git Add list-pids command to ustctl v2 Changes since v1: * Case pid_t to long Signed-off-by: Nils Carlson --- diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c index 807af8ca..18f7d307 100644 --- a/ustctl/ustctl.c +++ b/ustctl/ustctl.c @@ -213,6 +213,25 @@ static int get_sock_path(int argc, char *argv[]) return 0; } +static int list_pids(int argc, char *argv[]) +{ + pid_t *pid_list; + int i; + + pid_list = ustctl_get_online_pids(); + if (!pid_list) { + return -1; + } + + for (i = 0; pid_list[i]; i++) { + printf("%ld\n", (long)pid_list[i]); + } + + free(pid_list); + + return 0; +} + struct cli_cmd __cli_cmds general_cmds[] = { { .name = "list-trace-events", @@ -241,4 +260,13 @@ struct cli_cmd __cli_cmds general_cmds[] = { .desired_args = 1, .desired_args_op = CLI_EQ, }, + { + .name = "list-pids", + .description = "List traceable pids", + .help_text = "list-pids\n" + "List the traceable pids for the current user\n", + .function = list_pids, + .desired_args = 0, + .desired_args_op = CLI_EQ, + }, };