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