Date: Fri, 19 Jan 1996 18:11:55 +0300 (MSK) From: "Andrew Maltsev" <am@px.f1.ru> To: freebsd-hackers@freebsd.org Subject: setproctitle() Message-ID: <199601191511.SAA05118@px.f1.ru>
next in thread | raw e-mail | index | archive | help
Hi, All!
Why we have no interface to change process name in FreeBSD?
Like setproctitle() in BSD/OS and some other OS'es..
The following is my source, based on old source code from BSD/386 1.1
or 1.0.. I don't remember.
I tested it a bit.. Somebody from core team - what about to add a module
to libc.a? I'm not sure about man page - there is no BSD/OS near me to
check man's presense and copyright notices..
/************************************************************
* setproctitle(const char *fmt, ...) - process name changer
* Adopted for FreeBSD by Andrew Maltsev
*/
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/param.h>
#include <vm/vm.h>
#include <sys/exec.h>
void
setproctitle(const char *fmt, ...)
{
va_list ap;
int n;
char c = '\0';
char *buf = &c;
struct ps_strings *psp = (struct ps_strings *)PS_STRINGS;
va_start(ap, fmt);
n = vsnprintf(buf, 1, fmt, ap);
va_end(ap);
if ((buf = malloc(++n)) == 0)
return;
va_start(ap, fmt);
vsnprintf(buf, n, fmt, ap);
va_end(ap);
psp->ps_argvstr = buf;
/* Not sure about this line - for what? But leaved as is to make it
* compatible with BSD/OS
*/
psp->ps_nargvstr = 1;
}
#ifdef DEBUG
main()
{ setproctitle("Wow, my pid is %d!",getpid());
system("ps");
}
#endif
--
am
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601191511.SAA05118>
