[PATCH] smemcap: keep outputting by ignoring transient processes
Walter Harms
wharms at bfs.de
Fri Aug 24 07:15:21 UTC 2018
I am sorry i missed the point,
this patch solves what probelm ?
re,
wh
Am 23.08.2018 23:44, schrieb Andre Goddard Rosa:
> 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 */
More information about the busybox
mailing list