From dda18a7833ea4e74c6ead7777c455467a2c129f4 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 15 Oct 2019 13:40:13 +0100 Subject: [PATCH] Revert "compat: Fix setproctitle on Solaris" This reverts commit c085a2836f8439bc3e9d01a85d399afb8ad1dc12. --- compat/setproctitle.c | 18 +++++------------- compat/setproctitle.h | 4 +--- src/dhcpcd.c | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/compat/setproctitle.c b/compat/setproctitle.c index c1d4d705..9350e5ee 100644 --- a/compat/setproctitle.c +++ b/compat/setproctitle.c @@ -30,28 +30,24 @@ #include #include "config.h" -#include "dhcpcd.h" #ifdef __sun #define SETPROCTITLE_PAD ' ' -extern const char **environ; #else #define SETPROCTITLE_PAD '\0' #endif -static struct dhcpcd_ctx *setproctitle_ctx; static int setproctitle_argc; -static const char *setproctitle_argv_last; +static char *setproctitle_argv_last; static char **setproctitle_argv; static char *setproctitle_buf; int -setproctitle_init(struct dhcpcd_ctx *ctx, int argc, char **argv) +setproctitle_init(int argc, char **argv) { size_t i, len; char *p; - setproctitle_ctx = ctx; len = 0; for (i = 0; environ[i] != NULL; i++) len += strlen(environ[i]) + 1; @@ -123,20 +119,16 @@ setproctitle(const char *fmt, ...) int i; len = 0; - for (i = 0; i < setproctitle_ctx->argc; i++) { - len += strlen(setproctitle_ctx->argv[i]) + 1; - } + for (i = 0; i < setproctitle_argc; i++) + len += strlen(setproctitle_argv[i]) + 1; if (len > (size_t)(p - setproctitle_argv[0])) { p += strlcpy(p, " (", LAST_SIZE); for (i = 0; i < setproctitle_argc; i++) { - p += strlcpy(p, setproctitle_ctx->argv[i], LAST_SIZE); + p += strlcpy(p, setproctitle_argv[i], LAST_SIZE); p += strlcpy(p, " ", LAST_SIZE); } } - - if (*(p - 1) == ' ') - *(p - 1) = ')'; #endif if (setproctitle_argv_last - p > 0) diff --git a/compat/setproctitle.h b/compat/setproctitle.h index ede12650..18249947 100644 --- a/compat/setproctitle.h +++ b/compat/setproctitle.h @@ -28,8 +28,6 @@ #ifndef SETPROCTITLE_H #define SETPROCTITLE_H -#include "dhcpcd.h" - #ifndef __printflike #if __GNUC__ > 2 || defined(__INTEL_COMPILER) #define __printflike(a, b) __attribute__((format(printf, a, b))) @@ -38,7 +36,7 @@ #endif #endif /* !__printflike */ -int setproctitle_init(struct dhcpcd_ctx *ctx, int, char **); +int setproctitle_init(int, char **); void setproctitle_free(void); __printflike(1, 2) void setproctitle(const char *, ...); #endif diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 0349b148..85d9081f 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -2026,7 +2026,7 @@ printpidfile: ctx.options |= DHCPCD_STARTED; #ifdef SETPROCTITLE_H - setproctitle_init(&ctx, argc, argv); + setproctitle_init(argc, argv); #endif setproctitle("%s%s%s", ctx.options & DHCPCD_MASTER ? "[master]" : argv[optind], -- 2.47.2