mirror of
https://github.com/samba-team/samba.git
synced 2025-03-25 14:50:24 +03:00
lib/util: Make prctl_set_comment take a printf format string
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>
This commit is contained in:
parent
575d39048e
commit
efb3aa95c5
@ -20,15 +20,21 @@
|
||||
*/
|
||||
|
||||
#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;
|
||||
|
@ -22,6 +22,8 @@
|
||||
#ifndef _SAMBA_UTIL_PROCESS_H
|
||||
#define _SAMBA_UTIL_PROCESS_H
|
||||
|
||||
#include "replace.h"
|
||||
|
||||
/**
|
||||
* @brief Set the process comment name.
|
||||
*
|
||||
@ -30,6 +32,6 @@
|
||||
*
|
||||
* @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
|
||||
|
@ -513,7 +513,7 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
|
||||
}
|
||||
|
||||
if (comment) {
|
||||
prctl_set_comment(comment);
|
||||
prctl_set_comment("%s", comment);
|
||||
}
|
||||
|
||||
done:
|
||||
|
Loading…
x
Reference in New Issue
Block a user