mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
Use a compatible with BSD's setproctitle.
This commit is contained in:
@@ -17,15 +17,24 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/prctl.h>
|
||||
|
||||
/* This sets the proccess title as shown in top, but not in ps (*@#%@).
|
||||
* To change the ps name in Linux, one needs to do master black magic
|
||||
* trickery (set util-linux setproctitle).
|
||||
*/
|
||||
void setproctitle (const char *prog)
|
||||
void setproctitle (const char *fmt, ...)
|
||||
{
|
||||
#ifdef PR_SET_NAME
|
||||
prctl (PR_SET_NAME, prog);
|
||||
char name[16];
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(name, sizeof(name)-1, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
prctl (PR_SET_NAME, name);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef SETPROCTITLE_H
|
||||
# define SETPROCTITLE_H
|
||||
|
||||
extern void setproctitle (const char *prog);
|
||||
void __attribute__ ((format(printf, 1, 2)))
|
||||
setproctitle(const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user