[Xfce4-commits] [apps/xfce4-taskmanager] 01/01: Silently and gracefully handle the case when a process disappears before we try to get its argv
noreply at xfce.org
noreply at xfce.org
Wed Dec 3 18:31:53 CET 2014
This is an automated email from the git hooks/post-receive script.
landry pushed a commit to branch master
in repository apps/xfce4-taskmanager.
commit 69f56371baf09ec2c38b82e3888df3e70e21871b
Author: Landry Breuil <landry at xfce.org>
Date: Wed Dec 3 18:30:34 2014 +0100
Silently and gracefully handle the case when a process disappears before we try to get its argv
---
src/task-manager-bsd.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/task-manager-bsd.c b/src/task-manager-bsd.c
index 3c952fa..f37e4c2 100644
--- a/src/task-manager-bsd.c
+++ b/src/task-manager-bsd.c
@@ -37,6 +37,9 @@
#include <sys/vmmeter.h>
#include "task-manager.h"
+#include <errno.h>
+extern int errno;
+
char *state_abbrev[] = {
"", "start", "run", "sleep", "stop", "zomb", "dead", "onproc"
};
@@ -112,16 +115,22 @@ gboolean get_task_list (GArray *task_list)
if (!P_ZOMBIE(&p)) {
size = 128;
if ((args = malloc(size)) == NULL)
- errx(1,"failed to allocate memory for argv structures");
+ errx(1,"failed to allocate memory for argv structures at %zu", size);
for (;; size *= 2) {
if ((args = realloc(args, size)) == NULL)
- errx(1,"failed to allocate memory for argv structures of pid %d",t.pid);
+ errx(1,"failed to allocate memory (size=%zu) for argv structures of pid %d", size, t.pid);
mib[0] = CTL_KERN;
mib[1] = KERN_PROC_ARGS;
mib[2] = t.pid;
mib[3] = KERN_PROC_ARGV;
if (sysctl(mib, 4, args, &size, NULL, 0) == 0)
break;
+ if (errno != ENOMEM) { /* ESRCH: process disappeared */
+ /* printf ("process with pid %d disappeared, errno=%d\n", t.pid, errno); */
+ args[0] ='\0';
+ args[1] = NULL;
+ break;
+ }
}
buf[0] = '\0';
for (ptr = args; *ptr != NULL; ptr++) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list