initctl: initical conversion to use libuEv for top command

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-05 23:56:39 +02:00
parent 8ed223343d
commit 02936de993
2 changed files with 13 additions and 14 deletions
+2 -2
View File
@@ -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
View File
@@ -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);
}
/**