aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/gen/setproctitle.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/setproctitle.c')
-rw-r--r--lib/libc/gen/setproctitle.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c
index b975fd72b649..991af38565cd 100644
--- a/lib/libc/gen/setproctitle.c
+++ b/lib/libc/gen/setproctitle.c
@@ -184,8 +184,18 @@ setproctitle_fast(const char *fmt, ...)
oid[0] = CTL_KERN;
oid[1] = KERN_PROC;
oid[2] = KERN_PROC_ARGS;
- oid[3] = getpid();
- sysctl(oid, 4, 0, 0, "", 0);
+ oid[3] = -1;
+ if (sysctl(oid, 4, 0, 0, "", 0) != 0) {
+ /*
+ * Temporary compat for kernels which don't support
+ * passing -1.
+ */
+ oid[0] = CTL_KERN;
+ oid[1] = KERN_PROC;
+ oid[2] = KERN_PROC_ARGS;
+ oid[3] = getpid();
+ sysctl(oid, 4, 0, 0, "", 0);
+ }
fast_update = 1;
}
}
@@ -206,8 +216,18 @@ setproctitle(const char *fmt, ...)
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);
+ oid[3] = -1;
+ if (sysctl(oid, 4, 0, 0, buf, strlen(buf) + 1) != 0) {
+ /*
+ * Temporary compat for kernels which don't support
+ * passing -1.
+ */
+ 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);
+ }
fast_update = 0;
}
}