#include <stdarg.h>
#include <unistd.h>
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+
#include <avahi-common/malloc.h>
#include "setproctitle.h"
#endif
}
-void avahi_set_proc_title(const char *fmt,...) {
+void avahi_set_proc_title(const char *name, const char *fmt,...) {
#ifdef HAVE_SETPROCTITLE
char t[256];
va_list ap;
- va_start(ap);
+ va_start(ap, fmt);
vsnprintf(t, sizeof(t), fmt, ap);
va_end(ap);
memset(argv_buffer[0] + l, 0, argv_size - l);
argv_buffer[1] = NULL;
#endif
+
+#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_NAME)
+
+ if (name)
+ prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0);
+
+#endif
}