mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-18 11:39:03 +02:00
Implement sendmail semantics for setproctitle()
Prefix the title with "progname: ", and skip it if the format string starts with '-' (which gets skipped on output too).
This commit is contained in:
@@ -203,8 +203,18 @@ setproctitle(const char *fmt, ...)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
|
if (fmt[0] == '-') {
|
||||||
|
/* Skip program name prefix. */
|
||||||
|
fmt++;
|
||||||
|
len = 0;
|
||||||
|
} else {
|
||||||
|
/* Print program name heading for grep. */
|
||||||
|
snprintf(buf, sizeof(buf), "%s: ", getprogname());
|
||||||
|
len = strlen(buf);
|
||||||
|
}
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
len = vsnprintf(buf, sizeof(buf), fmt, ap);
|
len += vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
} else {
|
} else {
|
||||||
len = snprintf(buf, sizeof(buf), "%s", SPT.arg0);
|
len = snprintf(buf, sizeof(buf), "%s", SPT.arg0);
|
||||||
|
Reference in New Issue
Block a user