This makes it easier to pass a small amount of variable information
into the buffer, to distinguish processes in the AD DC.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14287
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
*/
#include "util_process.h"
-#include "config.h"
+#include "replace.h"
#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
-int prctl_set_comment(const char *comment)
+int prctl_set_comment(const char *comment_format, ...)
{
#if defined(HAVE_PRCTL) && defined(PR_SET_NAME)
+ char comment[16];
+ va_list ap;
+ va_start(ap, comment_format);
+ vsnprintf(comment, sizeof(comment), comment_format, ap);
+ va_end(ap);
+
return prctl(PR_SET_NAME, (unsigned long) comment, 0, 0, 0);
#endif
return 0;
#ifndef _SAMBA_UTIL_PROCESS_H
#define _SAMBA_UTIL_PROCESS_H
+#include "replace.h"
+
/**
* @brief Set the process comment name.
*
*
* @return -1 on error, 0 on success.
*/
-int prctl_set_comment(const char *comment);
+int prctl_set_comment(const char *comment_format, ...) PRINTF_ATTRIBUTE(1,2);
#endif
}
if (comment) {
- prctl_set_comment(comment);
+ prctl_set_comment("%s", comment);
}
done: