Use a compatible with BSD's setproctitle.

This commit is contained in:
Nikos Mavrogiannopoulos
2013-02-09 00:33:39 +01:00
parent 39373b605c
commit 779ed61893
2 changed files with 13 additions and 3 deletions

View File

@@ -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
}

View File

@@ -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