}
}
-/* Changes the name of the process, as shown by "ps", to 'format', which is
- * formatted as if by printf(). */
+/* Changes the name of the process, as shown by "ps", to the program name
+ * followed by 'format', which is formatted as if by printf(). */
void
proctitle_set(const char *format, ...)
{
}
va_start(args, format);
- n = vsnprintf(argv_start, argv_size, format, args);
+ n = snprintf(argv_start, argv_size, "%s: ", program_name);
+ if (n < argv_size) {
+ n += vsnprintf(argv_start + n, argv_size - n, format, args);
+ }
if (n >= argv_size) {
/* The name is too long, so add an ellipsis at the end. */
strcpy(&argv_start[argv_size - 4], "...");
int retval;
int status;
- proctitle_set("%s: monitoring pid %lu (%s)",
- program_name, (unsigned long int) daemon_pid,
- status_msg);
+ proctitle_set("monitoring pid %lu (%s)",
+ (unsigned long int) daemon_pid, status_msg);
do {
retval = waitpid(daemon_pid, &status, 0);
server_sock = fd;
subprogram_name = "worker";
- proctitle_set("%s: worker process for pid %lu",
- program_name, (unsigned long int) getppid());
+ proctitle_set("worker process for pid %lu", (unsigned long int) getppid());
VLOG_INFO("worker process started");
rxbuf_init(&rx);