[PATCH] smemcap: keep outputting by ignoring transient processes

Denys Vlasenko vda.linux at googlemail.com
Sun Aug 26 15:38:13 UTC 2018


Applied, thanks
On Fri, Aug 24, 2018 at 12:16 AM Andre Goddard Rosa <andre.rosa at lge.com> wrote:
>
> 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
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list