diff options
author | bde <bde@FreeBSD.org> | 1998-12-16 17:34:05 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-12-16 17:34:05 +0000 |
commit | c3648dbd002cd14130169c03ed921789e290a103 (patch) | |
tree | 44c92d2acb0e0eca999a48fe43632d38f4412231 | |
parent | 2b1259bfa214f11b4e1309f81321328bf8eeed05 (diff) | |
download | FreeBSD-src-c3648dbd002cd14130169c03ed921789e290a103.zip FreeBSD-src-c3648dbd002cd14130169c03ed921789e290a103.tar.gz |
Adjust for kern.ps_strings and PS_STRINGS not being a pointer. This is
an unimprovement here. I thought it would be an improvement, as in libkvm,
but here we can access the strings directly.
Use sysctlbyname() instead of sysctl() and trust it to give a nonzero
address if it succeeds.
-rw-r--r-- | lib/libc/gen/setproctitle.c | 15 | ||||
-rw-r--r-- | lib/libutil/setproctitle.c | 15 |
2 files changed, 14 insertions, 16 deletions
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c index 217df06..3bce420 100644 --- a/lib/libc/gen/setproctitle.c +++ b/lib/libc/gen/setproctitle.c @@ -14,7 +14,7 @@ * 3. Absolutely no warranty of function or purpose is made by the author * Peter Wemm. * - * $Id: setproctitle.c,v 1.6 1998/04/28 06:59:14 dg Exp $ + * $Id: setproctitle.c,v 1.7 1998/04/28 07:02:33 dg Exp $ */ #include <sys/types.h> @@ -72,8 +72,8 @@ setproctitle(fmt, va_alist) static char buf[SPT_BUFSIZE]; static char *ps_argv[2]; va_list ap; - int mib[2]; size_t len; + unsigned long ul_ps_strings; #if defined(__STDC__) va_start(ap, fmt); @@ -104,12 +104,11 @@ setproctitle(fmt, va_alist) va_end(ap); if (ps_strings == NULL) { - mib[0] = CTL_KERN; - mib[1] = KERN_PS_STRINGS; - len = sizeof(ps_strings); - if (sysctl(mib, 2, &ps_strings, &len, NULL, 0) < 0 || - ps_strings == NULL) - ps_strings = PS_STRINGS; + len = sizeof(ul_ps_strings); + if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL, + 0) == -1) + ul_ps_strings = PS_STRINGS; + ps_strings = (struct ps_strings *)ul_ps_strings; } /* PS_STRINGS points to zeroed memory on a style #2 kernel */ diff --git a/lib/libutil/setproctitle.c b/lib/libutil/setproctitle.c index 217df06..3bce420 100644 --- a/lib/libutil/setproctitle.c +++ b/lib/libutil/setproctitle.c @@ -14,7 +14,7 @@ * 3. Absolutely no warranty of function or purpose is made by the author * Peter Wemm. * - * $Id: setproctitle.c,v 1.6 1998/04/28 06:59:14 dg Exp $ + * $Id: setproctitle.c,v 1.7 1998/04/28 07:02:33 dg Exp $ */ #include <sys/types.h> @@ -72,8 +72,8 @@ setproctitle(fmt, va_alist) static char buf[SPT_BUFSIZE]; static char *ps_argv[2]; va_list ap; - int mib[2]; size_t len; + unsigned long ul_ps_strings; #if defined(__STDC__) va_start(ap, fmt); @@ -104,12 +104,11 @@ setproctitle(fmt, va_alist) va_end(ap); if (ps_strings == NULL) { - mib[0] = CTL_KERN; - mib[1] = KERN_PS_STRINGS; - len = sizeof(ps_strings); - if (sysctl(mib, 2, &ps_strings, &len, NULL, 0) < 0 || - ps_strings == NULL) - ps_strings = PS_STRINGS; + len = sizeof(ul_ps_strings); + if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL, + 0) == -1) + ul_ps_strings = PS_STRINGS; + ps_strings = (struct ps_strings *)ul_ps_strings; } /* PS_STRINGS points to zeroed memory on a style #2 kernel */ |