]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/libc/gen/setproctitle.3
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / libc / gen / setproctitle.3
1 .\" Copyright (c) 1995 Peter Wemm <peter@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, is permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice immediately at the beginning of the file, without modification,
9 .\"    this list of conditions, and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\" 3. This work was done expressly for inclusion into FreeBSD.  Other use
14 .\"    is permitted provided this notation is included.
15 .\" 4. Absolutely no warranty of function or purpose is made by the author
16 .\"    Peter Wemm.
17 .\" 5. Modifications may be freely made to this file providing the above
18 .\"    conditions are met.
19 .\"
20 .\" $FreeBSD$
21 .\"
22 .\" The following requests are required for all man pages.
23 .Dd December 16, 1995
24 .Dt SETPROCTITLE 3
25 .Os
26 .Sh NAME
27 .Nm setproctitle
28 .Nd set process title
29 .Sh SYNOPSIS
30 .In sys/types.h
31 .In unistd.h
32 .Ft void
33 .Fn setproctitle "const char *fmt" "..."
34 .Sh DESCRIPTION
35 The
36 .Fn setproctitle
37 library routine sets the process title that appears on the
38 .Xr ps 1
39 command.
40 .Pp
41 The title is set from the executable's name, followed by the
42 result of a
43 .Xr printf 3
44 style expansion of the arguments as specified by the
45 .Va fmt
46 argument.
47 If the
48 .Va fmt
49 argument begins with a
50 .Dq -
51 character, the executable's name is skipped.
52 .Pp
53 If
54 .Va fmt
55 is NULL, the process title is restored.
56 .Sh EXAMPLES
57 To set the title on a daemon to indicate its activity:
58 .Bd -literal -offset indent
59 setproctitle("talking to %s", inet_ntoa(addr));
60 .Ed
61 .Sh SEE ALSO
62 .Xr ps 1 ,
63 .Xr w 1 ,
64 .Xr kvm 3 ,
65 .Xr kvm_getargv 3 ,
66 .Xr printf 3
67 .Sh STANDARDS
68 The
69 .Fn setproctitle
70 function
71 is implicitly non-standard.
72 Other methods of causing the
73 .Xr ps 1
74 command line to change, including copying over the argv[0] string are
75 also implicitly non-portable.
76 It is preferable to use an operating system
77 supplied
78 .Fn setproctitle
79 if present.
80 .Pp
81 Unfortunately, it is possible that there are other calling conventions
82 to other versions of
83 .Fn setproctitle ,
84 although none have been found by the author as yet.
85 This is believed to be
86 the predominant convention.
87 .Pp
88 It is thought that the implementation is compatible with other systems,
89 including
90 .Nx
91 and
92 .Bsx .
93 .Sh HISTORY
94 The
95 .Fn setproctitle
96 function
97 first appeared in
98 .Fx 2.2 .
99 Other operating systems have
100 similar functions.
101 .Sh AUTHORS
102 .An -nosplit
103 .An Peter Wemm Aq peter@FreeBSD.org
104 stole the idea from the
105 .Sy "Sendmail 8.7.3"
106 source code by
107 .An Eric Allman Aq eric@sendmail.org .
108 .Sh BUGS
109 Never pass a string with user-supplied data as a format without using
110 .Ql %s .
111 An attacker can put format specifiers in the string to mangle your stack,
112 leading to a possible security hole.
113 This holds true even if the string was built using a function like
114 .Fn snprintf ,
115 as the resulting string may still contain user-supplied conversion specifiers
116 for later interpolation by
117 .Fn setproctitle .
118 .Pp
119 Always use the proper secure idiom:
120 .Pp
121 .Dl setproctitle("%s", string);