]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add support for setproctitle(3).
authorRoy Marples <roy@marples.name>
Tue, 13 Feb 2018 10:22:31 +0000 (10:22 +0000)
committerRoy Marples <roy@marples.name>
Tue, 13 Feb 2018 10:22:31 +0000 (10:22 +0000)
configure
src/dhcpcd.c

index 0eccc10487138085ab7088d2a31c732d9dda51fb..5282322ca5cdfde406f9af860b3fbe6fd59391c8 100755 (executable)
--- a/configure
+++ b/configure
@@ -799,6 +799,27 @@ else
        fi
 fi
 
+if [ -z "$SETPROCTITLE" ]; then
+       printf "Testing for setproctitle ... "
+       cat << EOF >_setproctitle.c
+#include <stdlib.h>
+int main(void) {
+       setproctitle("foo");
+       return 0;
+}
+EOF
+       if $XCC _setproctitle.c -o _setproctitle 2>&3; then
+               SETPROCTITLE=yes
+       else
+               SETPROCTITLE=no
+       fi
+       echo "$SETPROCTITLE"
+       rm -f _setproctitle.c _setproctitle
+fi
+if [ "$SETPROCTITLE" = yes ]; then
+       echo "#define   HAVE_SETPROCTITLE" >>$CONFIG_H
+fi
+
 if [ -z "$STRTOI" ]; then
        printf "Testing for strtoi ... "
        cat <<EOF >_strtoi.c
index d025ccdf43d737a3181bcdc992d888249d503a9e..7e214c38ae43f621cbe2f728d4b3db36969b5335 100644 (file)
@@ -1809,6 +1809,13 @@ printpidfile:
        logdebugx(PACKAGE "-" VERSION " starting");
        ctx.options |= DHCPCD_STARTED;
 
+#ifdef HAVE_SETPROCTITLE
+       setproctitle("%s%s%s",
+           ctx.options & DHCPCD_MASTER ? "[master]" : argv[optind],
+           ctx.options & DHCPCD_IPV4 ? " [ip4]" : "",
+           ctx.options & DHCPCD_IPV6 ? " [ip6]" : "");
+#endif
+
        if (if_opensockets(&ctx) == -1) {
                logerr("%s: if_opensockets", __func__);
                goto exit_failure;