summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-11-16 20:31:58 +0000
committerphk <phk@FreeBSD.org>1999-11-16 20:31:58 +0000
commitcc6b664e2eb821b39837e7bb980e5ee87e201491 (patch)
tree65eeb4add32e588f36f28e2a0bb819c17a67ff70 /lib/libutil
parent47e5f46c7642e6d8e2ed20c8afca59596d3c2dc1 (diff)
downloadFreeBSD-src-cc6b664e2eb821b39837e7bb980e5ee87e201491.zip
FreeBSD-src-cc6b664e2eb821b39837e7bb980e5ee87e201491.tar.gz
Introduce commandline caching in the kernel.
This fixes some nasty procfs problems for SMP, makes ps(1) run much faster, and makes ps(1) even less dependent on /proc which will aid chroot and jails alike. To disable this facility and revert to previous behaviour: sysctl -w kern.ps_arg_cache_limit=0 For full details see the current@FreeBSD.org mail-archives.
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/setproctitle.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libutil/setproctitle.c b/lib/libutil/setproctitle.c
index a5cf234..36c21db 100644
--- a/lib/libutil/setproctitle.c
+++ b/lib/libutil/setproctitle.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <unistd.h>
/*
* Older FreeBSD 2.0, 2.1 and 2.2 had different ps_strings structures and
@@ -74,6 +75,7 @@ setproctitle(fmt, va_alist)
va_list ap;
size_t len;
unsigned long ul_ps_strings;
+ int oid[4];
#if defined(__STDC__)
va_start(ap, fmt);
@@ -103,6 +105,13 @@ setproctitle(fmt, va_alist)
va_end(ap);
+ /* Set the title into the kernel cached command line */
+ oid[0] = CTL_KERN;
+ oid[1] = KERN_PROC;
+ oid[2] = KERN_PROC_ARGS;
+ oid[3] = getpid();
+ sysctl(oid, 4, 0, 0, buf, strlen(buf) + 1);
+
if (ps_strings == NULL) {
len = sizeof(ul_ps_strings);
if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL,
OpenPOWER on IntegriCloud