1 From 4a8707f25a8825c90987ed25906d5dfd5288aaf9 Mon Sep 17 00:00:00 2001
2 From: Sam Liddicott <sam@liddicott.com>
3 Date: Fri, 19 Apr 2013 11:04:55 +0100
4 Subject: [PATCH] Support setproctitle on linux with prctl(PR_SET_NAME
6 Only the first 16 characters of the title are used on Linux systems
7 so the most relevant data should be presented at the start of the
10 Signed-off-by: Sam Liddicott <sam@liddicott.com>
12 lib/replace/replace.c | 19 +++++++++++++++++++
13 1 file changed, 19 insertions(+)
15 diff --git a/lib/replace/replace.c b/lib/replace/replace.c
16 index 37edb31..00abad8 100644
17 --- a/lib/replace/replace.c
18 +++ b/lib/replace/replace.c
20 #include "system/locale.h"
21 #include "system/wait.h"
23 +/* Linux replacement for setproctitle */
24 +#if ! defined(HAVE_SETPROCTITLE) && defined(HAVE_SYS_PRCTL_H) && defined(HAVE_PRCTL)
25 +#include <sys/prctl.h>
29 #define mkdir(d,m) _mkdir(d)
31 @@ -898,5 +903,19 @@ int rep_usleep(useconds_t sec)
32 #ifndef HAVE_SETPROCTITLE
33 void rep_setproctitle(const char *fmt, ...)
35 +#if defined (HAVE_PRCTL) && defined(PR_SET_NAME)
40 + va_start(args, fmt);
41 + vasprintf(&title, fmt, args);
42 + prctl(PR_SET_NAME, (unsigned long)title, 0, 0, 0);
46 + prctl(PR_SET_NAME, 0, 0, 0, 0);
54 --- a/lib/replace/wscript~ 2014-09-08 11:26:14.000000000 +0200
55 +++ b/lib/replace/wscript 2014-10-28 22:05:54.003836383 +0100
56 @@ -311,8 +311,7 @@ def configure(conf):
58 if not conf.CHECK_FUNCS('getpeereid'):
59 conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
60 - if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
61 - conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h')
62 + conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h')
63 if not conf.CHECK_FUNCS('setproctitle_init'):
64 conf.CHECK_FUNCS_IN('setproctitle_init', 'bsd', headers='sys/types.h bsd/unistd.h')