tail head cat sleep
QR code linking to this page

Manual Pages  — GETPROGNAME


getprogname, setprogname – get or set the program name



Standard C Library (libc, -lc)


#include <stdlib.h>

const char *

setprogname(const char *progname);


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.


err(3), setproctitle(3)


These functions first appeared in NetBSD and made their way into FreeBSD 4.4 .

GETPROGNAME (3) May 1, 2001

tail head cat sleep
QR code linking to this page

Please direct any comments about this manual page service to Ben Bullock. Privacy policy.

This philosophy, in the hands of amateurs, leads to inexplicably mind-numbing botches like the existence of two programs, “head” and “tail,” which print the first part or the last part of a file, depending. Even though their operations are duals of one another, “head” and “tail” are different programs, written by different authors, and take different options!
— The Unix Haters' handbook