1.\" 2.\" This file and its contents are supplied under the terms of the 3.\" Common Development and Distribution License ("CDDL"), version 1.0. 4.\" You may only use this file in accordance with the terms of version 5.\" 1.0 of the CDDL. 6.\" 7.\" A full copy of the text of the CDDL should have accompanied this 8.\" source. A copy of the CDDL is also available via the Internet at 9.\" http://www.illumos.org/license/CDDL. 10.\" 11.\" 12.\" Copyright (c) 2014, Joyent, Inc. 13.\" 14.Dd "Nov 26, 2017" 15.Dt GETPROGNAME 3C 16.Os 17.Sh NAME 18.Nm getprogname , 19.Nm setprogname 20.Nd get or set the program name 21.Sh SYNOPSIS 22.In stdlib.h 23.Ft const char * 24.Fo getprogname 25.Fa void 26.Fc 27.Ft void 28.Fo setprogname 29.Fa "const char *progname" 30.Fc 31.Sh DESCRIPTION 32The 33.Fn getprogname 34function is used to obtain the program name. 35The program name is set at program start-up, before 36.Fn main 37is called. 38Note, other operating systems, do not guarantee that a program name has been set 39at start up time and therefore may return a null pointer if 40.Fn setprogname 41has not been called. 42.Lp 43The 44.Fn setprogname 45function is used to change the program name to another value. 46The argument 47.Fa progname 48must contain a null terminated character string, whose last component 49which will become the new program name. 50.Sh RETURN VALUES 51The 52.Fn getprogname 53function always returns the current program name. 54The program name is always set, it will not return a null pointer. 55.Sh INTERFACE STABILITY 56.Sy Committed 57.Sh MT-LEVEL 58.Fn getprogname 59is 60.Sy MT-Safe . 61.Lp 62.Fn setprogname 63is 64.Sy Unsafe . 65.Sh SEE ALSO 66.Xr err 3c , 67.Xr attributes 5 68.Sh NOTES 69The use of 70.Fn setprogname 71does not modify the program name as reported by utilities like 72.Xr ps 1 73or 74.Xr pargs 1 ; 75however, it does ensure a consistent program name for the 76.Xr err 3C 77family of functions. 78