]> granicus.if.org Git - psmisc/commitdiff
pstree: do not crash on missing /proc/xxxx directory
authorPiotr Praszmo <piotr.praszmo@nokia.com>
Wed, 23 Oct 2019 12:11:01 +0000 (14:11 +0200)
committerCraig Small <csmall@dropbear.xyz>
Thu, 14 Nov 2019 22:49:57 +0000 (09:49 +1100)
This can happen when process ends while pstree is running.
Ignore such processes.

src/pstree.c

index 99881e9cc9c5224bb1b18648c2688d2bb0ae9599..3de0792c63eb3b7176058fb431afc1447ffd48b7 100644 (file)
@@ -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) {