]> granicus.if.org Git - procps-ng/commitdiff
slabtop: return failure if /proc/slabinfo cannot be accessed
authorSami Kerola <kerolasa@iki.fi>
Sun, 26 Feb 2012 22:20:14 +0000 (23:20 +0100)
committerCraig Small <csmall@enc.com.au>
Sat, 3 Mar 2012 07:36:29 +0000 (18:36 +1100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
slabtop.c

index 1a3bbd8ad0174f588c702cb9cd180db268a6a297..567556aed1b2a4e22e66f9d85f3740ca939a35c5 100644 (file)
--- a/slabtop.c
+++ b/slabtop.c
@@ -276,7 +276,7 @@ int main(int argc, char *argv[])
        int o;
        unsigned short old_rows;
        struct slab_info *slab_list = NULL;
-       int run_once=0;
+       int run_once = 0, retval = EXIT_SUCCESS;
 
        static const struct option longopts[] = {
                { "delay",      required_argument, NULL, 'd' },
@@ -342,8 +342,10 @@ int main(int argc, char *argv[])
                int i;
                memset(&stats, 0, sizeof(struct slab_stat));
 
-               if (get_slabinfo(&slab_list, &stats))
+               if (get_slabinfo(&slab_list, &stats)) {
+                       retval = EXIT_FAILURE;
                        break;
+               }
 
                if (!run_once && old_rows != rows) {
                        resizeterm(rows, cols);
@@ -409,6 +411,7 @@ int main(int argc, char *argv[])
 
        tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_tty);
        free_slabinfo(slab_list);
-       if (!run_once) endwin();
-       return EXIT_SUCCESS;
+       if (!run_once)
+               endwin();
+       return retval;
 }