From e545b2e71622c3268c10b0a171002a9353a1f647 Mon Sep 17 00:00:00 2001 From: Mike Massonnet Date: Wed, 9 Sep 2009 20:24:24 +0200 Subject: [PATCH] Show command line arguments in Linux --- ChangeLog | 13 +++++++++++++ TODO | 1 - src/taskmanager-linux.c | 16 +++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index aee2187..3e6086e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-09-09 Mike Massonnet + + * Show command line arguments in Linux. + +2009-09-08 Mike Massonnet + + * Update Solaris patch from Peter Tribble. + * Check for the lib kstat in the autoconf script. + * Build with the correct file for Solaris in the automake script. + * Fixed the xfce_err messages and switched to g_snprintf for the + command strings. + * Updated the TODO file. + 2009-09-03 Mike Massonnet * Add support for Solaris from Peter Tribble diff --git a/TODO b/TODO index 0554cbe..81dda5e 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -+ drop old gtk_tooltips + support multi core (show cpu usage per process) + move get_cpu_usage() out from functions.c, it is an os-dependant function + change priority numbers against an enum with text labels Low Medium Normal diff --git a/src/taskmanager-linux.c b/src/taskmanager-linux.c index 2e92be1..90b49c5 100644 --- a/src/taskmanager-linux.c +++ b/src/taskmanager-linux.c @@ -31,8 +31,9 @@ static void get_cmdline(gint pid, gchar *cmdline, gint length, gchar *cmdline_fu FILE *file; char filename[255]; char *p; + char *args = NULL; int c; - int i = 0; + int i = 0, j = 0; char buffer[4096]; int idummy; @@ -47,6 +48,9 @@ static void get_cmdline(gint pid, gchar *cmdline, gint length, gchar *cmdline_fu if (c != 0) { cmdline_full[i++] = c; } else { + if (args == NULL) { + args = cmdline_full + i; + } cmdline_full[i++] = ' '; } @@ -60,6 +64,9 @@ static void get_cmdline(gint pid, gchar *cmdline, gint length, gchar *cmdline_fu cmdline_full[i] = '\0'; } + if (args != NULL && args[0] == '\0') + args = NULL; + fclose (file); /* daemon processes and kernel processes don't have a cmdline */ @@ -105,6 +112,13 @@ static void get_cmdline(gint pid, gchar *cmdline, gint length, gchar *cmdline_fu } } + if (args != NULL) { + for (i = strlen(cmdline), j = 0; args[j] != '\0' && i < length - 1; i++, j++) { + cmdline[i] = args[j]; + } + cmdline[i] = '\0'; + } + if (cmdline[0] == '-') { for (i = 0; cmdline[i] != '\0'; i++) { cmdline[i] = cmdline[i+1];