2011-06-04 22:28:25 +05:30
|
|
|
/*
|
2004-01-25 04:03:56 +05:30
|
|
|
* slabtop.c - utility to display kernel slab information.
|
|
|
|
*
|
|
|
|
* Chris Rivera <cmrivera@ufl.edu>
|
|
|
|
* Robert Love <rml@tech9.net>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Chris Rivera
|
2012-03-02 17:59:36 +05:30
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-01-25 04:03:56 +05:30
|
|
|
*/
|
|
|
|
|
2011-11-03 21:37:47 +05:30
|
|
|
#include <locale.h>
|
2004-01-25 04:03:56 +05:30
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <ncurses.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <sys/ioctl.h>
|
2005-01-06 02:20:54 +05:30
|
|
|
|
2004-01-25 04:03:56 +05:30
|
|
|
#include <sys/select.h>
|
2005-01-06 02:20:54 +05:30
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2004-01-25 04:03:56 +05:30
|
|
|
|
2011-10-09 06:19:51 +05:30
|
|
|
#include "c.h"
|
2012-03-23 18:02:24 +05:30
|
|
|
#include "fileutils.h"
|
2011-10-09 06:19:51 +05:30
|
|
|
#include "nls.h"
|
2011-12-18 19:42:06 +05:30
|
|
|
#include "strutils.h"
|
2004-01-25 04:03:56 +05:30
|
|
|
#include "proc/slab.h"
|
|
|
|
#include "proc/version.h"
|
|
|
|
|
|
|
|
#define DEF_SORT_FUNC sort_nr_objs
|
|
|
|
|
|
|
|
static unsigned short cols, rows;
|
|
|
|
static struct termios saved_tty;
|
|
|
|
static long delay = 3;
|
|
|
|
static int (*sort_func)(const struct slab_info *, const struct slab_info *);
|
|
|
|
|
|
|
|
static struct slab_info *merge_objs(struct slab_info *a, struct slab_info *b)
|
|
|
|
{
|
|
|
|
struct slab_info sorted_list;
|
|
|
|
struct slab_info *curr = &sorted_list;
|
|
|
|
|
|
|
|
while ((a != NULL) && (b != NULL)) {
|
|
|
|
if (sort_func(a, b)) {
|
|
|
|
curr->next = a;
|
|
|
|
curr = a;
|
|
|
|
a = a->next;
|
|
|
|
} else {
|
|
|
|
curr->next = b;
|
|
|
|
curr = b;
|
|
|
|
b = b->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
curr->next = (a == NULL) ? b : a;
|
|
|
|
return sorted_list.next;
|
|
|
|
}
|
|
|
|
|
2011-06-04 22:28:25 +05:30
|
|
|
/*
|
2004-01-25 04:03:56 +05:30
|
|
|
* slabsort - merge sort the slab_info linked list based on sort_func
|
|
|
|
*/
|
|
|
|
static struct slab_info *slabsort(struct slab_info *list)
|
|
|
|
{
|
|
|
|
struct slab_info *a, *b;
|
|
|
|
|
|
|
|
if ((list == NULL) || (list->next == NULL))
|
|
|
|
return list;
|
|
|
|
|
|
|
|
a = list;
|
|
|
|
b = list->next;
|
|
|
|
|
|
|
|
while ((b != NULL) && (b->next != NULL)) {
|
|
|
|
list = list->next;
|
|
|
|
b = b->next->next;
|
|
|
|
}
|
2013-03-31 10:30:00 +05:30
|
|
|
|
2004-01-25 04:03:56 +05:30
|
|
|
b = list->next;
|
|
|
|
list->next = NULL;
|
|
|
|
|
|
|
|
return merge_objs(slabsort(a), slabsort(b));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sort Routines. Each of these should be associated with a command-line
|
|
|
|
* search option. The functions should fit the prototype:
|
|
|
|
*
|
|
|
|
* int sort_foo(const struct slab_info *a, const struct slab_info *b)
|
|
|
|
*
|
|
|
|
* They return one if the first parameter is larger than the second
|
|
|
|
* Otherwise, they return zero.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int sort_name(const struct slab_info *a, const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (strcmp(a->name, b->name) < 0) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sort_nr_objs(const struct slab_info *a, const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->nr_objs > b->nr_objs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sort_nr_active_objs(const struct slab_info *a,
|
|
|
|
const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->nr_active_objs > b->nr_active_objs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sort_obj_size(const struct slab_info *a, const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->obj_size > b->obj_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sort_objs_per_slab(const struct slab_info *a,
|
|
|
|
const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->objs_per_slab > b->objs_per_slab);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sort_pages_per_slab(const struct slab_info *a,
|
|
|
|
const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->pages_per_slab > b->pages_per_slab);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sort_nr_slabs(const struct slab_info *a, const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->nr_slabs > b->nr_slabs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sort_nr_active_slabs(const struct slab_info *a,
|
|
|
|
const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->nr_active_slabs > b->nr_active_slabs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int sort_use(const struct slab_info *a, const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->use > b->use);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sort_cache_size(const struct slab_info *a, const struct slab_info *b)
|
|
|
|
{
|
|
|
|
return (a->cache_size > b->cache_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* term_size - set the globals 'cols' and 'rows' to the current terminal size
|
|
|
|
*/
|
2011-06-04 22:28:25 +05:30
|
|
|
static void term_size(int unusused __attribute__ ((__unused__)))
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
|
|
|
struct winsize ws;
|
|
|
|
|
2011-06-04 22:28:25 +05:30
|
|
|
if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1) && ws.ws_row > 10) {
|
2004-01-25 04:03:56 +05:30
|
|
|
cols = ws.ws_col;
|
|
|
|
rows = ws.ws_row;
|
|
|
|
} else {
|
|
|
|
cols = 80;
|
|
|
|
rows = 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-04 22:28:25 +05:30
|
|
|
static void sigint_handler(int unused __attribute__ ((__unused__)))
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
|
|
|
delay = 0;
|
|
|
|
}
|
|
|
|
|
2011-06-04 22:28:25 +05:30
|
|
|
static void __attribute__((__noreturn__)) usage(FILE *out)
|
2004-01-25 04:03:56 +05:30
|
|
|
{
|
2011-10-09 06:19:51 +05:30
|
|
|
fputs(USAGE_HEADER, out);
|
2011-12-17 23:02:47 +05:30
|
|
|
fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
|
2011-10-09 06:19:51 +05:30
|
|
|
fputs(USAGE_OPTIONS, out);
|
2013-12-28 03:55:39 +05:30
|
|
|
fputs(_(" -d, --delay <secs> delay updates\n"), out);
|
|
|
|
fputs(_(" -o, --once only display once, then exit\n"), out);
|
|
|
|
fputs(_(" -s, --sort <char> specify sort criteria by character (see below)\n"), out);
|
2011-10-09 06:19:51 +05:30
|
|
|
fputs(USAGE_SEPARATOR, out);
|
|
|
|
fputs(USAGE_HELP, out);
|
|
|
|
fputs(USAGE_VERSION, out);
|
|
|
|
|
2013-12-28 03:55:39 +05:30
|
|
|
fputs(_("\nThe following are valid sort criteria:\n"), out);
|
|
|
|
fputs(_(" a: sort by number of active objects\n"), out);
|
|
|
|
fputs(_(" b: sort by objects per slab\n"), out);
|
|
|
|
fputs(_(" c: sort by cache size\n"), out);
|
|
|
|
fputs(_(" l: sort by number of slabs\n"), out);
|
|
|
|
fputs(_(" v: sort by number of active slabs\n"), out);
|
|
|
|
fputs(_(" n: sort by name\n"), out);
|
|
|
|
fputs(_(" o: sort by number of objects (the default)\n"), out);
|
|
|
|
fputs(_(" p: sort by pages per slab\n"), out);
|
|
|
|
fputs(_(" s: sort by object size\n"), out);
|
|
|
|
fputs(_(" u: sort by cache utilization\n"), out);
|
2011-10-09 06:19:51 +05:30
|
|
|
fprintf(out, USAGE_MAN_TAIL("slabtop(1)"));
|
2011-06-04 22:28:25 +05:30
|
|
|
|
|
|
|
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set_sort_func - return the slab_sort_func that matches the given key.
|
|
|
|
* On unrecognizable key, DEF_SORT_FUNC is returned.
|
|
|
|
*/
|
|
|
|
static void * set_sort_func(char key)
|
|
|
|
{
|
|
|
|
switch (key) {
|
|
|
|
case 'n':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_name;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'o':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_nr_objs;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'a':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_nr_active_objs;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 's':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_obj_size;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'b':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_objs_per_slab;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'p':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_pages_per_slab;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'l':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_nr_slabs;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'v':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_nr_active_slabs;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'c':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_cache_size;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'u':
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) sort_use;
|
2004-01-25 04:03:56 +05:30
|
|
|
default:
|
2011-06-04 22:28:25 +05:30
|
|
|
return (void *) DEF_SORT_FUNC;
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void parse_input(char c)
|
|
|
|
{
|
|
|
|
c = toupper(c);
|
|
|
|
switch(c) {
|
|
|
|
case 'A':
|
|
|
|
sort_func = sort_nr_active_objs;
|
|
|
|
break;
|
|
|
|
case 'B':
|
|
|
|
sort_func = sort_objs_per_slab;
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
sort_func = sort_cache_size;
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
sort_func = sort_nr_slabs;
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
sort_func = sort_nr_active_slabs;
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
sort_func = sort_name;
|
|
|
|
break;
|
|
|
|
case 'O':
|
|
|
|
sort_func = sort_nr_objs;
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
sort_func = sort_pages_per_slab;
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
sort_func = sort_obj_size;
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
sort_func = sort_use;
|
|
|
|
break;
|
|
|
|
case 'Q':
|
|
|
|
delay = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-26 17:05:43 +05:30
|
|
|
#define print_line(fmt, ...) if (run_once) printf(fmt, __VA_ARGS__); else printw(fmt, __VA_ARGS__)
|
2004-01-25 04:03:56 +05:30
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int o;
|
|
|
|
unsigned short old_rows;
|
|
|
|
struct slab_info *slab_list = NULL;
|
2012-02-27 03:50:14 +05:30
|
|
|
int run_once = 0, retval = EXIT_SUCCESS;
|
2004-01-25 04:03:56 +05:30
|
|
|
|
2011-06-04 22:28:25 +05:30
|
|
|
static const struct option longopts[] = {
|
|
|
|
{ "delay", required_argument, NULL, 'd' },
|
|
|
|
{ "sort", required_argument, NULL, 's' },
|
|
|
|
{ "once", no_argument, NULL, 'o' },
|
|
|
|
{ "help", no_argument, NULL, 'h' },
|
|
|
|
{ "version", no_argument, NULL, 'V' },
|
|
|
|
{ NULL, 0, NULL, 0 }
|
2004-01-25 04:03:56 +05:30
|
|
|
};
|
|
|
|
|
2013-02-20 23:01:48 +05:30
|
|
|
#ifdef HAVE_PROGRAM_INVOCATION_NAME
|
2012-01-03 13:18:43 +05:30
|
|
|
program_invocation_name = program_invocation_short_name;
|
2013-02-20 23:01:48 +05:30
|
|
|
#endif
|
2011-11-03 21:37:47 +05:30
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
textdomain(PACKAGE);
|
2012-03-23 18:02:24 +05:30
|
|
|
atexit(close_stdout);
|
2011-11-03 21:37:47 +05:30
|
|
|
|
2004-01-25 04:03:56 +05:30
|
|
|
sort_func = DEF_SORT_FUNC;
|
|
|
|
|
|
|
|
while ((o = getopt_long(argc, argv, "d:s:ohV", longopts, NULL)) != -1) {
|
|
|
|
switch (o) {
|
|
|
|
case 'd':
|
|
|
|
errno = 0;
|
2011-12-18 19:42:06 +05:30
|
|
|
delay = strtol_or_err(optarg, _("illegal delay"));
|
|
|
|
if (delay < 1)
|
2012-01-03 13:18:43 +05:30
|
|
|
xerrx(EXIT_FAILURE,
|
2011-12-18 19:42:06 +05:30
|
|
|
_("delay must be positive integer"));
|
2004-01-25 04:03:56 +05:30
|
|
|
break;
|
|
|
|
case 's':
|
2011-06-04 22:28:25 +05:30
|
|
|
sort_func = (int (*)(const struct slab_info*,
|
|
|
|
const struct slab_info *)) set_sort_func(optarg[0]);
|
2004-01-25 04:03:56 +05:30
|
|
|
break;
|
|
|
|
case 'o':
|
2011-06-04 22:28:25 +05:30
|
|
|
run_once=1;
|
2004-01-25 04:03:56 +05:30
|
|
|
delay = 0;
|
|
|
|
break;
|
|
|
|
case 'V':
|
2011-10-09 06:19:51 +05:30
|
|
|
printf(PROCPS_NG_VERSION);
|
2011-06-04 22:28:25 +05:30
|
|
|
return EXIT_SUCCESS;
|
2004-01-25 04:03:56 +05:30
|
|
|
case 'h':
|
2011-06-04 22:28:25 +05:30
|
|
|
usage(stdout);
|
2004-01-25 04:03:56 +05:30
|
|
|
default:
|
2011-06-04 22:28:25 +05:30
|
|
|
usage(stderr);
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-04 22:28:25 +05:30
|
|
|
if (tcgetattr(STDIN_FILENO, &saved_tty) == -1)
|
2012-01-03 13:18:43 +05:30
|
|
|
xwarn(_("terminal setting retrieval"));
|
2004-01-25 04:03:56 +05:30
|
|
|
|
|
|
|
old_rows = rows;
|
2011-12-02 17:06:38 +05:30
|
|
|
term_size(0);
|
2011-06-04 22:28:25 +05:30
|
|
|
if (!run_once) {
|
|
|
|
initscr();
|
|
|
|
resizeterm(rows, cols);
|
|
|
|
signal(SIGWINCH, term_size);
|
|
|
|
}
|
2004-01-25 04:03:56 +05:30
|
|
|
signal(SIGINT, sigint_handler);
|
|
|
|
|
|
|
|
do {
|
|
|
|
struct slab_info *curr;
|
2011-06-04 22:28:25 +05:30
|
|
|
struct slab_stat stats;
|
2004-01-25 04:03:56 +05:30
|
|
|
struct timeval tv;
|
|
|
|
fd_set readfds;
|
|
|
|
char c;
|
|
|
|
int i;
|
2011-06-04 22:28:25 +05:30
|
|
|
memset(&stats, 0, sizeof(struct slab_stat));
|
2004-01-25 04:03:56 +05:30
|
|
|
|
2012-02-27 03:50:14 +05:30
|
|
|
if (get_slabinfo(&slab_list, &stats)) {
|
|
|
|
retval = EXIT_FAILURE;
|
2004-01-25 04:03:56 +05:30
|
|
|
break;
|
2012-02-27 03:50:14 +05:30
|
|
|
}
|
2004-01-25 04:03:56 +05:30
|
|
|
|
2011-12-02 17:06:38 +05:30
|
|
|
if (!run_once && old_rows != rows) {
|
2004-01-25 04:03:56 +05:30
|
|
|
resizeterm(rows, cols);
|
|
|
|
old_rows = rows;
|
|
|
|
}
|
|
|
|
|
2011-06-04 22:28:25 +05:30
|
|
|
move(0, 0);
|
2011-12-22 18:23:17 +05:30
|
|
|
print_line(" %-35s: %d / %d (%.1f%%)\n"
|
2011-10-09 06:19:51 +05:30
|
|
|
" %-35s: %d / %d (%.1f%%)\n"
|
|
|
|
" %-35s: %d / %d (%.1f%%)\n"
|
|
|
|
" %-35s: %.2fK / %.2fK (%.1f%%)\n"
|
|
|
|
" %-35s: %.2fK / %.2fK / %.2fK\n\n",
|
2011-12-17 23:02:47 +05:30
|
|
|
/* Translation Hint: Next five strings must not
|
|
|
|
* exceed 35 length in characters. */
|
2011-10-09 06:19:51 +05:30
|
|
|
_("Active / Total Objects (% used)"),
|
|
|
|
stats.nr_active_objs, stats.nr_objs,
|
|
|
|
100.0 * stats.nr_active_objs / stats.nr_objs,
|
|
|
|
_("Active / Total Slabs (% used)"),
|
|
|
|
stats.nr_active_slabs, stats.nr_slabs,
|
|
|
|
100.0 * stats.nr_active_slabs / stats.nr_slabs,
|
2012-01-06 00:09:41 +05:30
|
|
|
_("Active / Total Caches (% used)"),
|
|
|
|
stats.nr_active_caches, stats.nr_caches,
|
|
|
|
100.0 * stats.nr_active_caches / stats.nr_caches,
|
2011-10-09 06:19:51 +05:30
|
|
|
_("Active / Total Size (% used)"),
|
|
|
|
stats.active_size / 1024.0, stats.total_size / 1024.0,
|
|
|
|
100.0 * stats.active_size / stats.total_size,
|
|
|
|
_("Minimum / Average / Maximum Object"),
|
|
|
|
stats.min_obj_size / 1024.0, stats.avg_obj_size / 1024.0,
|
|
|
|
stats.max_obj_size / 1024.0);
|
2004-01-25 04:03:56 +05:30
|
|
|
|
|
|
|
slab_list = slabsort(slab_list);
|
|
|
|
|
|
|
|
attron(A_REVERSE);
|
2011-12-17 23:02:47 +05:30
|
|
|
/* Translation Hint: Please keep alignment of the
|
|
|
|
* following intact. */
|
2011-12-22 18:23:17 +05:30
|
|
|
print_line("%-78s\n", _(" OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME"));
|
2004-01-25 04:03:56 +05:30
|
|
|
attroff(A_REVERSE);
|
|
|
|
|
|
|
|
curr = slab_list;
|
|
|
|
for (i = 0; i < rows - 8 && curr->next; i++) {
|
2011-12-02 17:06:38 +05:30
|
|
|
print_line("%6u %6u %3u%% %7.2fK %6u %8u %9uK %-23s\n",
|
2004-01-25 04:03:56 +05:30
|
|
|
curr->nr_objs, curr->nr_active_objs, curr->use,
|
|
|
|
curr->obj_size / 1024.0, curr->nr_slabs,
|
2005-01-06 03:16:22 +05:30
|
|
|
curr->objs_per_slab, (unsigned)(curr->cache_size / 1024),
|
2004-01-25 04:03:56 +05:30
|
|
|
curr->name);
|
|
|
|
curr = curr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
put_slabinfo(slab_list);
|
2011-12-02 17:06:38 +05:30
|
|
|
if (!run_once) {
|
2011-06-04 22:28:25 +05:30
|
|
|
refresh();
|
|
|
|
FD_ZERO(&readfds);
|
|
|
|
FD_SET(STDIN_FILENO, &readfds);
|
|
|
|
tv.tv_sec = delay;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
if (select(STDOUT_FILENO, &readfds, NULL, NULL, &tv) > 0) {
|
2012-03-09 02:19:49 +05:30
|
|
|
if (read(STDIN_FILENO, &c, 1) != 1)
|
2011-06-04 22:28:25 +05:30
|
|
|
break;
|
|
|
|
parse_input(c);
|
|
|
|
}
|
|
|
|
}
|
2004-01-25 04:03:56 +05:30
|
|
|
} while (delay);
|
|
|
|
|
2011-06-04 22:28:25 +05:30
|
|
|
tcsetattr(STDIN_FILENO, TCSAFLUSH, &saved_tty);
|
2004-01-25 04:03:56 +05:30
|
|
|
free_slabinfo(slab_list);
|
2012-02-27 03:50:14 +05:30
|
|
|
if (!run_once)
|
|
|
|
endwin();
|
|
|
|
return retval;
|
2004-01-25 04:03:56 +05:30
|
|
|
}
|