[PATCH] smemcap: keep outputting by ignoring transient processes
Andre Goddard Rosa
andre.rosa at lge.com
Thu Aug 23 21:44:45 UTC 2018
Signed-off-by: Andre Goddard Rosa <andre.rosa at lge.com>
---
procps/smemcap.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/procps/smemcap.c b/procps/smemcap.c
index 81f4cafad..1fa27a6c4 100644
--- a/procps/smemcap.c
+++ b/procps/smemcap.c
@@ -65,14 +65,22 @@ 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;
prev = &cur->next;
r = full_read(fd, cur->data, TAR_BLOCK_SIZE);
- if (r > 0)
+ if (r > 0) {
size += r;
+ } else if (r == -1) {
+ close(fd);
+ return;
+ }
} while (r == TAR_BLOCK_SIZE);
/* write archive header */
--
2.19.0.rc0.2.g29d9e3e2c4
More information about the busybox
mailing list