diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-10-23 16:43:16 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-10-23 16:43:16 +0000 |
commit | ef67e62f06441585786d79be3626e33e4e0fc9d0 (patch) | |
tree | 1d39d64639a2c92653abb4e4f4e9f61614abb3d2 /lib/libc/gen | |
parent | 11d896b111f547be1b21f9c909b24b4bdbd5b661 (diff) |
use psstrings sysctl
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/setproctitle.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c index e5575561547..0561748a04f 100644 --- a/lib/libc/gen/setproctitle.c +++ b/lib/libc/gen/setproctitle.c @@ -30,7 +30,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.2 1996/08/19 08:25:59 tholo Exp $"; +static char rcsid[] = "$OpenBSD: setproctitle.c,v 1.3 1996/10/23 16:43:03 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -61,11 +61,13 @@ setproctitle(fmt, va_alist) va_dcl #endif { + static struct ps_strings *ps; va_list ap; + static char buf[MAX_PROCTITLE], *bufp = buf; int used; -#if __STDC__ +if __STDC__ va_start(ap, fmt); #else va_start(ap); @@ -77,6 +79,17 @@ setproctitle(fmt, va_alist) (void)snprintf(buf, MAX_PROCTITLE, "%s", __progname); va_end(ap); - PS_STRINGS->ps_nargvstr = 1; - PS_STRINGS->ps_argvstr = &bufp; + if (ps == NULL) { + struct _ps_strings _ps; + int mib[2]; + size_t len; + + mib[0] = CTL_VM; + mib[1] = VM_PSSTRINGS; + len = sizeof(_ps); + sysctl(mib, 2, &_ps, &len, NULL, 0); + ps = (struct ps_strings *)_ps.val; + } + ps->ps_nargvstr = 1; + ps->ps_argvstr = &bufp; } |