mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
lib: Move addition of program_name to proctitle_set
Signed-off-by: Ed Maste <emaste@adaranet.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -140,8 +140,8 @@ proctitle_init(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* 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, ...)
|
||||
{
|
||||
@@ -157,7 +157,10 @@ 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], "...");
|
||||
|
Reference in New Issue
Block a user