|File: [cvs.NetBSD.org] / src / lib / libc / gen / getprogname.3 (download)
Revision 1.8, Sat May 21 19:06:44 2011 UTC (2 years ago) by dholland
CVS Tags: yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-nbase, tls-maxphys-base, tls-maxphys, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, cherry-xenmp-base, cherry-xenmp, agc-symver-base, agc-symver, HEAD
Changes since 1.7: +11 -10
Clarify paragraph about calling setprogname, requested by Tobias Ulmer on
freenode. Bump date.
.\" $NetBSD: getprogname.3,v 1.8 2011/05/21 19:06:44 dholland Exp $
.\" Copyright (c) 2001 Christopher G. Demetriou
.\" All rights reserved.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed for the
.\" NetBSD Project. See http://www.NetBSD.org/ for
.\" information about NetBSD.
.\" 4. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
.Dd May 21, 2011
.Dt GETPROGNAME 3
.Nm getprogname ,
.Nd get/set the name of the current program
.Ft const char *
.Fn getprogname "void"
.Fn setprogname "const char *name"
These utility functions get and set the current program's name
as used by various error-reporting functions.
returns the name of the current program.
This function is typically useful when generating error messages
or other diagnostic output.
If the program name has not been set,
.Dv NULL .
sets the name of the current program to be the last pathname
component of the
It should be invoked at the start of the program, using the
passed into the program's
A pointer into the string pointed to by the
argument is kept as the program name.
Therefore, the string pointed to by
should not be modified during the rest of the program's operation.
A program's name can only be set once, and in
that is actually
done by program start-up code that is run before
explicitly has no effect.
However, portable programs that wish to use
.Fn main .
On operating systems where
are implemented via a portability library, this call is needed to
make the name available.
.Sh SEE ALSO
.Xr err 3 ,
.Xr setproctitle 3
function calls appeared in
.Nx 1.6 .
The string returned by
is supplied by the invoking process and should not be trusted by
setuid or setgid programs.