initctl: initical conversion to use libuEv for top command

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-04-05 23:56:39 +02:00
1 parent 8ed223343d
commit 02936de993
2 files changed
+13 -14

No files matched your search

+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 \ client.c client.h cond.c cond.h reboot.c \
serv.c serv.h svc.h util.c util.h serv.c serv.h svc.h util.c util.h
initctl_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99 initctl_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99
initctl_CFLAGS += $(lite_CFLAGS) initctl_CFLAGS += $(lite_CFLAGS) $(uev_CFLAGS)
initctl_LDADD = $(lite_LIBS) initctl_LDADD = $(lite_LIBS) $(uev_LIBS)
INIT_LNKS = init telinit INIT_LNKS = init telinit
REBOOT_LNKS = reboot shutdown halt poweroff suspend 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); 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) int show_cgtop(char *arg)
{ {
struct sysinfo si = { 0 }; struct sysinfo si = { 0 };
char path[512]; char path[512];
int laps = 0; uev_ctx_t ctx;
uev_t timer;
if (!arg) if (!arg)
arg = FINIT_CGPATH; arg = FINIT_CGPATH;
@@ -480,18 +487,10 @@ int show_cgtop(char *arg)
sysinfo(&si); sysinfo(&si);
total_ram = si.totalram * si.mem_unit; total_ram = si.totalram * si.mem_unit;
while (1) { uev_init(&ctx);
fputs("\e[2J\e[1;1H", stdout); uev_timer_init(&ctx, &timer, cgtop, arg, 1, ionce ? 0 : 1000);
if (heading)
print_header(" VmSIZE RSS VmLIB %%MEM %%CPU GROUP");
cgroup_tree(arg, NULL, 1);
if (ionce && laps++) return uev_run(&ctx, 0);
break;
sleep(1);
}
return 0;
} }
/** /**