]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpd: invoke `setproctitle_init()` when needed
authorVincent Bernat <vincent.bernat@dailymotion.com>
Mon, 15 Jul 2013 13:46:36 +0000 (15:46 +0200)
committerVincent Bernat <vincent.bernat@dailymotion.com>
Mon, 15 Jul 2013 13:46:36 +0000 (15:46 +0200)
On some systems, we need to invoke `setproctitle_init()` before using
`setproctitle()`.

configure.ac
src/daemon/lldpd.c
src/daemon/lldpd.h
src/daemon/main.c

index bec8ddc6b67f0fc77b2ef172658121fd702518c9..b95035ce22ccdbee86cbec04acc0f09f409740cc 100644 (file)
@@ -97,7 +97,9 @@ AC_CONFIG_LIBOBJ_DIR([src/compat])
 AC_FUNC_MALLOC
 AC_FUNC_REALLOC
 AC_SEARCH_LIBS([setproctitle], [util bsd])
-AC_REPLACE_FUNCS([strlcpy strnlen strndup fgetln setproctitle])
+AC_REPLACE_FUNCS([setproctitle])
+AC_CHECK_FUNCS([setproctitle_init])
+AC_REPLACE_FUNCS([strlcpy strnlen strndup fgetln])
 AC_CHECK_FUNCS([setresuid setresgid])
 
 case " $LIBS " in
index e07b3696a7b848ff8a7410e116cefd5d44e0f5d6..9ef39fb3b6e1b821d390063e6b7ef5ab561c87be 100644 (file)
@@ -1217,7 +1217,7 @@ lldpd_started_by_systemd()
 #endif
 
 int
-lldpd_main(int argc, char *argv[])
+lldpd_main(int argc, char *argv[], char *envp[])
 {
        struct lldpd *cfg;
        struct lldpd_chassis *lchassis;
@@ -1253,6 +1253,10 @@ lldpd_main(int argc, char *argv[])
 
        saved_argv = argv;
 
+#if HAVE_SETPROCTITLE_INIT
+       setproctitle_init(argc, argv, envp);
+#endif
+
        /*
         * Get and parse command line options
         */
index 30e103575bb16e444d0fa59ae3791ceab0ee2711..dc16e83c259ac09113f9429757fa55b081ed4ea2 100644 (file)
@@ -132,7 +132,7 @@ struct lldpd_mgmt *lldpd_alloc_mgmt(int family, void *addr, size_t addrsize, u_i
 void    lldpd_recv(struct lldpd *, struct lldpd_hardware *, int);
 void    lldpd_send(struct lldpd_hardware *);
 void    lldpd_loop(struct lldpd *);
-int     lldpd_main(int, char **);
+int     lldpd_main(int, char **, char **);
 void    lldpd_update_localports(struct lldpd *);
 void    lldpd_cleanup(struct lldpd *);
 
index cbcf9657114079eb3abee46630d2f43676936fac..c2d9297966f79a61612adb8099391c3a417aa198 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 int
-main(int argc, char **argv)
+main(int argc, char **argv, char **envp)
 {
-       return lldpd_main(argc, argv);
+       return lldpd_main(argc, argv, envp);
 }