mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
initctl: initical conversion to use libuEv for top command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+2
-2
@@ -62,8 +62,8 @@ initctl_SOURCES = initctl.c initctl.h cgutil.c cgutil.h \
|
||||
client.c client.h cond.c cond.h reboot.c \
|
||||
serv.c serv.h svc.h util.c util.h
|
||||
initctl_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99
|
||||
initctl_CFLAGS += $(lite_CFLAGS)
|
||||
initctl_LDADD = $(lite_LIBS)
|
||||
initctl_CFLAGS += $(lite_CFLAGS) $(uev_CFLAGS)
|
||||
initctl_LDADD = $(lite_LIBS) $(uev_LIBS)
|
||||
|
||||
INIT_LNKS = init telinit
|
||||
REBOOT_LNKS = reboot shutdown halt poweroff suspend
|
||||
|
||||
+11
-12
@@ -459,13 +459,20 @@ int show_cgroup(char *arg)
|
||||
}
|
||||
|
||||
return cgroup_tree(arg, NULL, 0);
|
||||
static void cgtop(uev_t *w, void *arg, int events)
|
||||
{
|
||||
fputs("\e[2J\e[1;1H", stdout);
|
||||
if (heading)
|
||||
print_header(" VmSIZE RSS VmLIB %%MEM %%CPU GROUP");
|
||||
cgroup_tree(arg, NULL, 1);
|
||||
}
|
||||
|
||||
int show_cgtop(char *arg)
|
||||
{
|
||||
struct sysinfo si = { 0 };
|
||||
char path[512];
|
||||
int laps = 0;
|
||||
uev_ctx_t ctx;
|
||||
uev_t timer;
|
||||
|
||||
if (!arg)
|
||||
arg = FINIT_CGPATH;
|
||||
@@ -480,18 +487,10 @@ int show_cgtop(char *arg)
|
||||
sysinfo(&si);
|
||||
total_ram = si.totalram * si.mem_unit;
|
||||
|
||||
while (1) {
|
||||
fputs("\e[2J\e[1;1H", stdout);
|
||||
if (heading)
|
||||
print_header(" VmSIZE RSS VmLIB %%MEM %%CPU GROUP");
|
||||
cgroup_tree(arg, NULL, 1);
|
||||
uev_init(&ctx);
|
||||
uev_timer_init(&ctx, &timer, cgtop, arg, 1, ionce ? 0 : 1000);
|
||||
|
||||
if (ionce && laps++)
|
||||
break;
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return uev_run(&ctx, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user