slabtop: return failure if /proc/slabinfo cannot be accessed

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-02-26 23:20:14 +01:00 committed by Craig Small
parent 00744108c6
commit 6dd921ca1c

View File

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