From b0e327e94bee063758356239ecd4d6adb83bb638 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 12 Jan 2015 06:18:31 -0600 Subject: [PATCH 11/12] initialize setproctitle where needed --- src/usr.sbin/ntpd/ntpd.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index af6d74d..d8ede39 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -111,6 +111,11 @@ usage(void) #define POLL_MAX 8 #define PFD_PIPE 0 +/* Saves a copy of argv for setproctitle emulation */ +#ifndef HAVE_SETPROCTITLE +static char **saved_argv; +#endif + int main(int argc, char *argv[]) { @@ -134,6 +139,17 @@ main(int argc, char *argv[]) log_init(1); /* log to stderr until daemonized */ +#ifndef HAVE_SETPROCTITLE + int i; + /* Prepare for later setproctitle emulation */ + saved_argv = calloc(argc + 1, sizeof(*saved_argv)); + for (i = 0; i < argc; i++) + saved_argv[i] = strdup(argv[i]); + saved_argv[i] = NULL; + compat_init_setproctitle(argc, argv); + argv = saved_argv; +#endif + while ((ch = getopt(argc, argv, "df:np:sSv")) != -1) { switch (ch) { case 'd': -- 1.9.1