GETPROGNAME(3)          NetBSD Library Functions Manual         GETPROGNAME(3)

     getprogname, setprogname -- get/set the name of the current program

     Standard C Library (libc, -lc)

     #include <stdlib.h>

     const char *

     setprogname(const char *name);

     These utility functions get and set the current program's name as used by
     various error-reporting functions.

     getprogname() returns the name of the current program.  This function is
     typically useful when generating error messages or other diagnostic out-
     put.  If the program name has not been set, getprogname() will return

     setprogname() sets the name of the current program to be the last path-
     name component of the name argument.  It should be invoked at the start
     of the program, using the argv[0] passed into the program's main() func-
     tion.  A pointer into the string pointed to by the name argument is kept
     as the program name.  Therefore, the string pointed to by name should not
     be modified during the rest of the program's operation.

     A program's name can only be set once, and in NetBSD that is actually
     done by program start-up code that is run before main() is called.
     Therefore, in NetBSD, calling setprogname() from main() has no effect.
     However, it does serve to increase the portability of the program: on
     other operating systems, getprogname() and setprogname() may be imple-
     mented by a portability library, and a call to setprogname() allows that
     library to know the program name without modifications to that system's
     program start-up code.

     err(3), setproctitle(3)

     The getprogname and setprogname function calls appeared in NetBSD 1.6.

     The string returned by getprogname() is supplied by the invoking process
     and should not be trusted by setuid or setgid programs.

NetBSD 5.1                      March 29, 2008                      NetBSD 5.1

You can also request any man page by name and (optionally) by section:


Use the DEFAULT collection to view manual pages for third-party software.

©1994 Man-cgi 1.15, Panagiotis Christias
©1996-2018 Modified for NetBSD by Kimmo Suominen