1GETPROGNAME(3bsd)                    LOCAL                   GETPROGNAME(3bsd)
2

NAME

4     getprogname, setprogname — get or set the program name
5

LIBRARY

7     Utility functions from BSD systems (libbsd, -lbsd)
8

SYNOPSIS

10     #include <stdlib.h>
11     (See libbsd(7) for include usage.)
12
13     const char *
14     getprogname(void);
15
16     void
17     setprogname(const char *progname);
18

DESCRIPTION

20     The getprogname() and setprogname() functions manipulate the name of the
21     current program.  They are used by error-reporting routines to produce
22     consistent output.
23
24     The getprogname() function returns the name of the program.  If the name
25     has not been set yet, it will return NULL.
26
27     The setprogname() function sets the name of the program to be the last
28     component of the progname argument.  Since a pointer to the given string
29     is kept as the program name, it should not be modified for the rest of
30     the program's lifetime.
31
32     In FreeBSD, the name of the program is set by the start-up code that is
33     run before main(); thus, running setprogname() is not necessary.  Pro‐
34     grams that desire maximum portability should still call it; on another
35     operating system, these functions may be implemented in a portability
36     library.  Calling setprogname() allows the aforementioned library to
37     learn the program name without modifications to the start-up code.
38

SEE ALSO

40     err(3), setproctitle(3bsd)
41

HISTORY

43     These functions first appeared in NetBSD 1.6, and made their way into
44     FreeBSD 4.4.
45
46BSD                               May 1, 2001                              BSD
Impressum