From: Piotr Praszmo Date: Wed, 23 Oct 2019 12:11:01 +0000 (+0200) Subject: pstree: do not crash on missing /proc/xxxx directory X-Git-Tag: v23.4rc1~29^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d21bee476432e0d0442662fa7899d4dd4897e097;p=psmisc pstree: do not crash on missing /proc/xxxx directory This can happen when process ends while pstree is running. Ignore such processes. --- 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) {