udhcpc: code shrink
[oweals/busybox.git] / procps / smemcap.c
index 9d1126a49a427c9b3cad8dbd5580de8491321c48..2f8ab192e2101c8445cee79c9299534d3b482ed1 100644 (file)
@@ -7,18 +7,17 @@
  the GNU General Public License version 2 or later, incorporated
  herein by reference.
 */
+//config:config SMEMCAP
+//config:      bool "smemcap (2.5 kb)"
+//config:      default y
+//config:      help
+//config:      smemcap is a tool for capturing process data for smem,
+//config:      a memory usage statistic tool.
 
 //applet:IF_SMEMCAP(APPLET(smemcap, BB_DIR_USR_BIN, BB_SUID_DROP))
 
 //kbuild:lib-$(CONFIG_SMEMCAP) += smemcap.o
 
-//config:config SMEMCAP
-//config:      bool "smemcap"
-//config:      default y
-//config:      help
-//config:        smemcap is a tool for capturing process data for smem,
-//config:        a memory usage statistic tool.
-
 #include "libbb.h"
 #include "bb_archive.h"
 
@@ -66,7 +65,11 @@ static void archivefile(const char *path)
        struct stat s;
 
        /* buffer the file */
-       fd = xopen(path, O_RDONLY);
+       fd = open(path, O_RDONLY);
+       if (fd == -1) {
+               /* skip vanished processes between dir listing and traversal */
+               return;
+       }
        do {
                cur = xzalloc(sizeof(*cur));
                *prev = cur;