Temporary “fix” of a nasty segfault

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.
This commit is contained in:
Mike Massonnet
2010-05-07 21:07:33 +02:00
parent 239c5d5064
commit 553be8eee1

View File

@@ -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);