psmisc/backport-0001-pstree-do-not-crash-on-missing-proc-xxxx-directory.patch
2020-11-03 16:08:43 +08:00

33 lines
962 B
Diff

From d21bee476432e0d0442662fa7899d4dd4897e097 Mon Sep 17 00:00:00 2001
From: Piotr Praszmo <piotr.praszmo@nokia.com>
Date: Wed, 23 Oct 2019 14:11:01 +0200
Subject: [PATCH 46/65] pstree: do not crash on missing /proc/xxxx directory
This can happen when process ends while pstree is running.
Ignore such processes.
https://gitlab.com/psmisc/psmisc/-/commit/d21bee476432e0d0442662fa7899d4dd4897e097
---
src/pstree.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/pstree.c b/src/pstree.c
index 99881e9..3de0792 100644
--- a/src/pstree.c
+++ b/src/pstree.c
@@ -1035,8 +1035,9 @@ static void read_proc(void)
}
#endif /*WITH_SELINUX */
if (stat(path, &st) < 0) {
- perror(path);
- exit(1);
+ (void) fclose(file);
+ free(path);
+ continue;
}
size = fread(readbuf, 1, BUFSIZ, file);
if (ferror(file) == 0) {
--
2.22.0.windows.1