From 553be8eee1d3a0e496d2f24dfb7b54c4e057ce7e Mon Sep 17 00:00:00 2001 From: Mike Massonnet Date: Fri, 7 May 2010 21:07:33 +0200 Subject: [PATCH] =?UTF-8?q?Temporary=20=E2=80=9Cfix=E2=80=9D=20of=20a=20na?= =?UTF-8?q?sty=20segfault?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On the Linux implementation, when a process name has a space in it the sscanf function is unable to parse the line properly. This will have to be changed, but in the meantime ignore such processes and avoid the segfault, there are going to be Beta releases. --- src/task-manager-linux.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/task-manager-linux.c b/src/task-manager-linux.c index 44704fe..56583cb 100644 --- a/src/task-manager-linux.c +++ b/src/task-manager-linux.c @@ -195,12 +195,13 @@ get_task_details (guint pid, Task *task) gulong jiffies_user, jiffies_system; struct passwd *pw; struct stat sstat; + guint ppid = 0; sscanf(buffer, "%i %255s %1s %i %i %i %i %i %255s %255s %255s %255s %255s %i %i %i %i %i %i %i %i %i %i %i %255s %255s %255s %i %255s %255s %255s %255s %255s %255s %255s %255s %255s %255s %i %255s %255s", &task->pid, // processid task->name, // processname task->state, // processstate - &task->ppid, // parentid + &ppid, // parentid &idummy, // processs groupid &idummy, // session id @@ -248,6 +249,11 @@ get_task_details (guint pid, Task *task) dummy ); + // FIXME sscanf sucks, big news, process names with spaces don't pass + if (ppid == 0) + return FALSE; + + task->ppid = ppid; task->rss *= get_pagesize (); get_cpu_percent (task->pid, jiffies_user, &task->cpu_user, jiffies_system, &task->cpu_system);