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 | |
parent | 11d896b111f547be1b21f9c909b24b4bdbd5b661 (diff) |
use psstrings sysctl
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/setproctitle.c | 21 | ||||
-rw-r--r-- | lib/libkvm.old/kvm_proc.c | 18 | ||||
-rw-r--r-- | lib/libkvm.old/shlib_version | 2 | ||||
-rw-r--r-- | lib/libkvm/kvm_proc.c | 19 |
4 files changed, 49 insertions, 11 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; } diff --git a/lib/libkvm.old/kvm_proc.c b/lib/libkvm.old/kvm_proc.c index 47116f821df..329768d9283 100644 --- a/lib/libkvm.old/kvm_proc.c +++ b/lib/libkvm.old/kvm_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc.c,v 1.1 1996/03/19 23:15:40 niklas Exp $ */ +/* $OpenBSD: kvm_proc.c,v 1.2 1996/10/23 16:43:12 deraadt Exp $ */ /*- * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved. @@ -756,12 +756,24 @@ kvm_doargv(kd, kp, nchr, info) u_long addr; int cnt; struct ps_strings arginfo; - + static struct ps_strings *ps; + + 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; + } /* * Pointers are stored at the top of the user stack. */ if (p->p_stat == SZOMB || - kvm_uread(kd, p, USRSTACK - sizeof(arginfo), (char *)&arginfo, + kvm_uread(kd, p, ps, (char *)&arginfo, sizeof(arginfo)) != sizeof(arginfo)) return (0); diff --git a/lib/libkvm.old/shlib_version b/lib/libkvm.old/shlib_version index d9961ea9fef..890c57389b5 100644 --- a/lib/libkvm.old/shlib_version +++ b/lib/libkvm.old/shlib_version @@ -1,2 +1,2 @@ major=4 -minor=0 +minor=1 diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c index 1aede825e90..71488797bf5 100644 --- a/lib/libkvm/kvm_proc.c +++ b/lib/libkvm/kvm_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc.c,v 1.2 1996/05/05 14:57:42 deraadt Exp $ */ +/* $OpenBSD: kvm_proc.c,v 1.3 1996/10/23 16:43:08 deraadt Exp $ */ /* $NetBSD: kvm_proc.c,v 1.16 1996/03/18 22:33:57 thorpej Exp $ */ /*- @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93"; #else -static char *rcsid = "$OpenBSD: kvm_proc.c,v 1.2 1996/05/05 14:57:42 deraadt Exp $"; +static char *rcsid = "$OpenBSD: kvm_proc.c,v 1.3 1996/10/23 16:43:08 deraadt Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -761,12 +761,25 @@ kvm_doargv(kd, kp, nchr, info) u_long addr; int cnt; struct ps_strings arginfo; + static struct ps_strings *ps; + + 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; + } /* * Pointers are stored at the top of the user stack. */ if (p->p_stat == SZOMB || - kvm_uread(kd, p, USRSTACK - sizeof(arginfo), (char *)&arginfo, + kvm_uread(kd, p, ps, (char *)&arginfo, sizeof(arginfo)) != sizeof(arginfo)) return (0); |