*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: getprogname | Section: 3 | Source: FreeBSD | File: getprogname.3.gz
GETPROGNAME(3) FreeBSD Library Functions Manual GETPROGNAME(3) NAME getprogname, setprogname - get or set the program name LIBRARY Standard C Library (libc, -lc) SYNOPSIS #include <stdlib.h> const char * getprogname(void); void setprogname(const char *progname); DESCRIPTION The getprogname() and setprogname() functions manipulate the name of the current program. They are used by error-reporting routines to produce consistent output. The getprogname() function returns the name of the program. If the name has not been set yet, it will return NULL. The setprogname() function sets the name of the program to be the last component of the progname argument. Since a pointer to the given string is kept as the program name, it should not be modified for the rest of the program's lifetime. In FreeBSD, the name of the program is set by the start-up code that is run before main(); thus, running setprogname() is not necessary. Programs that desire maximum portability should still call it; on another operating system, these functions may be implemented in a portability library. Calling setprogname() allows the aforementioned library to learn the program name without modifications to the start-up code. EXAMPLES The following example presents a simple program, which shows the difference between getprogname() and argv[0]. #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) { printf("getprogname(): %s\n", getprogname()); printf("argv[0]: %s\n", argv[0]); return (0); } When compiled and executed (e.g., with `./a.out') the output of the program is going to look like this: getprogname(): a.out argv[0]: ./a.out SEE ALSO err(3), setproctitle(3) HISTORY These functions first appeared in NetBSD 1.6, and made their way into FreeBSD 4.4. FreeBSD 14.1-RELEASE-p8 April 18, 2021 FreeBSD 14.1-RELEASE-p8

Navigation Options