File: setproctitle.c

package info (click to toggle)
socks4-server 4.3.beta2-9
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,532 kB
  • ctags: 1,777
  • sloc: ansic: 19,309; makefile: 400; sh: 69
file content (44 lines) | stat: -rw-r--r-- 765 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
**  SETPROCTITLE -- set process title for ps
**
**    Parameters:
**	    fmt -- a printf style format string.
**	    a, b, c -- possible parameters to fmt.
**
**    Returns:
**	    none.
**
**      Side Effects:
**	      Clobbers argv of our main procedure so ps(1) will
**	      display the title.
**
**    Stolen from IDA Sendmail - I don't think it's UCB code.
*/

#include <sys/types.h>
#include <string.h>

/*VARARGS1*/
socks_setproctitle(buf, Argv, LastArgv)
char *buf;
char **Argv, *LastArgv;
{
	register char *p;
	register int i;

	/* make ps print "(sockd)" */
	p = Argv[0];
	*p++ = '-';

	i = strlen(buf);
	if (i > LastArgv - p - 2)
	{
		i = LastArgv - p - 2;
		buf[i] = '\0';
	}
	(void) strcpy(p, buf);
	p += i;
	while (p < LastArgv)
		*p++ = ' ';
}