mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-01-09 19:27:42 +01:00
Warn when setproctitle() gets called before initialization
Try to give a helpful message in case the program is not initializing the setproctitle() machinery.
This commit is contained in:
parent
c5b9590287
commit
948bcf1db8
@ -28,6 +28,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -41,6 +42,7 @@ static struct {
|
||||
/* Pointer to original nul character within base. */
|
||||
char *nul;
|
||||
|
||||
bool warned;
|
||||
bool reset;
|
||||
int error;
|
||||
} SPT;
|
||||
@ -228,8 +230,14 @@ setproctitle_impl(const char *fmt, ...)
|
||||
char *nul;
|
||||
int len;
|
||||
|
||||
if (SPT.base == NULL)
|
||||
if (SPT.base == NULL) {
|
||||
if (!SPT.warned) {
|
||||
warnx("setproctitle not initialized, please either call "
|
||||
"setproctitle_init() or link against libbsd-ctor.");
|
||||
SPT.warned = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (fmt) {
|
||||
if (fmt[0] == '-') {
|
||||
|
Loading…
Reference in New Issue
Block a user