File: setprocn.c

package info (click to toggle)
ifmail 2.14tx8.10-32
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: ansic: 30,328; perl: 4,955; yacc: 839; makefile: 716; sh: 424; cpp: 235; lex: 206; awk: 24
file content (46 lines) | stat: -rw-r--r-- 788 bytes parent folder | download | duplicates (17)
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
45
46
#include <string.h>

#ifdef SETPROCTITLE
/*
 * clobber argv so ps will show what we're doing.
 * (stolen from BSD ftpd where it was stolen from sendmail)
 * warning, since this is usually started from inetd.conf, it
 * often doesn't have much of an environment or arglist to overwrite.
 */

static char *cmdstr=NULL;
static char *cmdstrend=NULL;

void setargspace(argv,envp)
char *argv[];
char *envp[];
{
	cmdstr=argv[0];
	while (*envp) envp++;
	envp--;
	cmdstrend=(*envp)+strlen(*envp);
}

void setproctitle(str)
char *str;
{
	char *p;

	/* make ps print our process name */
	for (p=cmdstr;(p < cmdstrend) && (*str);p++,str++) *p=*str;

	while (p < cmdstrend) *p++ = ' ';
}

#else

void setargspace(argv,envp)
char *argv[];
char *envp[];
{}

void setproctitle(str)
char *str;
{}

#endif