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