1getprogname(3bsd) LOCAL getprogname(3bsd)
2
4 getprogname, setprogname — get and set program name
5
7 Utility functions from BSD systems (libbsd, -lbsd)
8
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
20 The getprogname() returns a string with the current program name, exclud‐
21 ing any directory component. The function will return NULL if it was un‐
22 able to get the program name from any known source.
23
24 The setprogname() function sets the current program name, stripping any
25 directory component prefix. The function will keep a reference to the
26 passed string pointer, so it must not be freed or modified while these
27 functions might be called.
28
29 The implementations on most BSDs will try to initialize the program name
30 at program startup time, and libbsd will try to infer it from various
31 known sources depending on the target system. But it is not a portable
32 assumption that the program name will be set without calling
33 setprogname(), so portable programs should always call it after starting
34 up.
35
37 setproctitle(3bsd).
38
40 The setprogname() and getprogname() functions first appeared in
41 NetBSD 1.6, FreeBSD 4.4, DragonFly 2.1 and OpenBSD 5.4.
42
43BSD August 03, 2022 BSD