xref: /freebsd/lib/libc/gen/setproctitle.3 (revision df7f5d4de4592a8948a25ce01e5bddfbb7ce39dc)
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.\" $Id$
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 <libutil.h>
32.Ft void
33.Fn setproctitle "const char *fmt" "..."
34.Pp
35Link with
36.Va -lutil
37on the
38.Xr cc 1
39command line.
40.Sh DESCRIPTION
41The
42.Fn setproctitle
43library routine sets the process title that appears on the
44.Xr ps 1
45command.
46.Pp
47The title is set from the executable's name, followed by the
48result of a
49.Xr printf 3
50style expansion of the arguments as specified by the
51.Va fmt
52argument.
53.Pp
54If
55.Va fmt
56is NULL, the process title is reset to simply the name of the executable.
57.\" The following requests should be uncommented and used where appropriate.
58.\" This next request is for sections 2 and 3 function return values only.
59.\" .Sh RETURN VALUES
60.\" This next request is for sections 1, 6, 7 & 8 only
61.\" .Sh ENVIRONMENT
62.\" .Sh FILES
63.Sh EXAMPLES
64To set the title on a daemon to indicate it's activity:
65.Bd -literal -offset indent
66setproctitle("talking to %s", inet_ntoa(addr));
67.Ed
68.\" This next request is for sections 1, 6, 7 & 8 only
69.\"     (command return values (to shell) and fprintf/stderr type diagnostics)
70.\" .Sh DIAGNOSTICS
71.\" The next request is for sections 2 and 3 error and signal handling only.
72.\" .Sh ERRORS
73.Sh SEE ALSO
74.Xr ps 1 ,
75.Xr w 1 ,
76.Xr kvm 3 ,
77.Xr kvm_getargv 3 ,
78.Xr printf 3
79.Sh STANDARDS
80.Fn setproctitle
81is implicitly non-standard.  Other methods of causing the
82.Xr ps 1
83command line to change, including copying over the argv[0] string are
84also implicitly non-portable.  It is preferable to use an operating system
85supplied
86.Fn setproctitle
87if present.
88.Pp
89Unfortunately, it is possible that there are other calling conventions
90to other versions of
91.Fn setproctitle ,
92although none have been found by the author as yet.  This is believed to be
93the predominant convention.
94.Pp
95It is thought that the implementation is compatible with other systems,
96including
97.Tn NetBSD
98and
99.Tn BSD/OS .
100.Sh HISTORY
101.Fn setproctitle
102first appeared in
103.Fx 2.2 .
104Other operating systems have
105similar functions.
106.Sh AUTHORS
107.Sy "Peter Wemm <peter@FreeBSD.org>"
108stole the idea from the
109.Sy "Sendmail 8.7.3"
110source code by
111.Sy "Eric Allman <eric@sendmail.org>" .
112.\" .Sh BUGS
113