From 2ad6ee8ed15d1bf898645a16dbc06991a3c1425e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 25 Jan 2023 19:22:18 +0100 Subject: user: process titles, /bin/ps --- src/user/lib/stdlib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/user/lib/stdlib.c') diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index 5d1b09f..4e471ba 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -1,3 +1,4 @@ +#include <_proc.h> #include #include #include @@ -16,6 +17,19 @@ void setprogname(const char *pg) { progname = pg; } +void setproctitle(const char *fmt, ...) { + if (!fmt) { + strcpy(_libc_psdata, progname); + return; + } + sprintf(_libc_psdata, "%s: ", progname); + + va_list argp; + va_start(argp, fmt); + vsnprintf(_libc_psdata + strlen(_libc_psdata), 128, fmt, argp); + va_end(argp); +} + int mkstemp(char *template) { // TODO randomize template handle_t h = camellia_open(template, OPEN_CREATE | OPEN_RW); -- cgit v1.2.3