xref: /freebsd/lib/libc/gen/setproctitle.3 (revision 725ab6287fb4f78a5e98def40149d17f99eeb928)
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.Os FreeBSD
25.Dt SETPROCTITLE 3
26.Sh NAME
27.Nm setproctitle
28.Nd set the process title for
29.Xr ps 1
30.Sh SYNOPSIS
31.Fd #include <sys/types.h>
32.Fd #include <unistd.h>
33.Ft void
34.Fn setproctitle "const char *fmt" "..."
35.Sh DESCRIPTION
36The
37.Fn setproctitle
38library routine sets the process title that appears on the
39.Xr ps 1
40command.
41.Pp
42The title is set from the executable's name, followed by the
43result of a
44.Xr printf 3
45style expansion of the arguments as specified by the
46.Va fmt
47argument.
48If the
49.Va fmt
50argument begins with a
51.Dq -
52character, the executable's name is skipped.
53.Pp
54If
55.Va fmt
56is NULL, the process title is restored.
57.Sh EXAMPLES
58To set the title on a daemon to indicate its activity:
59.Bd -literal -offset indent
60setproctitle("talking to %s", inet_ntoa(addr));
61.Ed
62.Sh SEE ALSO
63.Xr ps 1 ,
64.Xr w 1 ,
65.Xr kvm 3 ,
66.Xr kvm_getargv 3 ,
67.Xr printf 3
68.Sh STANDARDS
69.Fn setproctitle
70is implicitly non-standard.  Other methods of causing the
71.Xr ps 1
72command line to change, including copying over the argv[0] string are
73also implicitly non-portable.  It is preferable to use an operating system
74supplied
75.Fn setproctitle
76if present.
77.Pp
78Unfortunately, it is possible that there are other calling conventions
79to other versions of
80.Fn setproctitle ,
81although none have been found by the author as yet.  This is believed to be
82the predominant convention.
83.Pp
84It is thought that the implementation is compatible with other systems,
85including
86.Nx
87and
88.Tn BSD/OS .
89.Sh HISTORY
90.Fn setproctitle
91first appeared in
92.Fx 2.2 .
93Other operating systems have
94similar functions.
95.Sh AUTHORS
96.An -nosplit
97.An Peter Wemm Aq peter@FreeBSD.org
98stole the idea from the
99.Sy "Sendmail 8.7.3"
100source code by
101.An Eric Allman Aq eric@sendmail.org .
102