2 .\" SPDX-License-Identifier: BSD-2-Clause
4 .\" Copyright (c) 1995 Peter Wemm
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" The following requests are required for all man pages.
38 .Fn setproctitle "const char *fmt" "..."
40 .Fn setproctitle_fast "const char *fmt" "..."
44 library routine sets the process title that appears on the
49 variant is optimized for high frequency updates, but may make the
51 command slightly slower by not updating the kernel cache of the program
54 The title is set from the executable's name, followed by the
57 style expansion of the arguments as specified by the
62 argument begins with a
64 character, the executable's name is skipped.
68 is NULL, the process title is restored.
70 To set the title on a daemon to indicate its activity:
71 .Bd -literal -offset indent
72 setproctitle("talking to %s", inet_ntoa(addr));
85 is implicitly non-standard.
86 Other methods of causing the
88 command line to change, including copying over the argv[0] string are
89 also implicitly non-portable.
90 It is preferable to use an operating system
95 Unfortunately, it is possible that there are other calling conventions
98 although none have been found by the author as yet.
99 This is believed to be
100 the predominant convention.
102 It is thought that the implementation is compatible with other systems,
114 .Fn setproctitle_fast
115 function first appeared in
117 Other operating systems have
121 .An Peter Wemm Aq Mt peter@FreeBSD.org
122 stole the idea from the
125 .An Eric Allman Aq Mt eric@sendmail.org .
127 Never pass a string with user-supplied data as a format without using
129 An attacker can put format specifiers in the string to mangle your stack,
130 leading to a possible security hole.
131 This holds true even if the string was built using a function like
133 as the resulting string may still contain user-supplied conversion specifiers
134 for later interpolation by
137 Always use the proper secure idiom:
139 .Dl setproctitle("%s", string);