summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/setproctitle.c21
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;
}