From fd8d4ec34785e71de3f8458222d196d454d0e723 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Sep 2012 09:20:46 +0200 Subject: replace: Support setproctitle(). This uses the setproctitle() from libc, libsetproctitle or libbsd. If none is available it provides a dummy implementation. --- lib/replace/README | 1 + lib/replace/replace.c | 7 +++++++ lib/replace/replace.h | 9 +++++++++ lib/replace/wscript | 2 ++ 4 files changed, 19 insertions(+) (limited to 'lib/replace') diff --git a/lib/replace/README b/lib/replace/README index 5399971afe..e960dc877e 100644 --- a/lib/replace/README +++ b/lib/replace/README @@ -73,6 +73,7 @@ readlink symlink realpath poll +setproctitle Types: bool diff --git a/lib/replace/replace.c b/lib/replace/replace.c index ebfe04d5d3..a0aa788658 100644 --- a/lib/replace/replace.c +++ b/lib/replace/replace.c @@ -894,3 +894,10 @@ int rep_usleep(useconds_t sec) return 0; } #endif /* HAVE_USLEEP */ + +#ifndef HAVE_SETPROCTITLE +void rep_setproctitle(const char *fmt, ...) +{ + return 0; +} +#endif diff --git a/lib/replace/replace.h b/lib/replace/replace.h index c7f9c71175..bbea0fc774 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -128,6 +128,10 @@ #include #endif +#ifdef HAVE_SETPROCTITLE_H +#include +#endif + #if STDC_HEADERS #include #include @@ -845,4 +849,9 @@ typedef long useconds_t; int usleep(useconds_t); #endif +#ifndef HAVE_SETPROCTITLE +#define setproctitle rep_setproctitle +void rep_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2); +#endif + #endif /* _LIBREPLACE_REPLACE_H */ diff --git a/lib/replace/wscript b/lib/replace/wscript index d5b2631cfd..f1f1cefe65 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -193,6 +193,8 @@ struct foo bar = { .y = 'X', .x = 1 }; checklibc=True) if not conf.CHECK_FUNCS('getpeereid'): conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h') + if not conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h'): + conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h') conf.CHECK_CODE(''' struct ucred cred; -- cgit