Debian Codegraph @

upstream/debian-unstable/man3/program_invocation_name.3

raw
1 .\" Copyright 2006, Michael Kerrisk <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" %%%LICENSE_START(PERMISSIVE_MISC)
5 .\" Permission is hereby granted, free of charge, to any person obtaining
6 .\" a copy of this software and associated documentation files (the
7 .\" "Software"), to deal in the Software without restriction, including
8 .\" without limitation the rights to use, copy, modify, merge, publish,
9 .\" distribute, sublicense, and/or sell copies of the Software, and to
10 .\" permit persons to whom the Software is furnished to do so, subject to
11 .\" the following conditions:
12 .\"
13 .\" The above copyright notice and this permission notice shall be
14 .\" included in all copies or substantial portions of the Software.
15 .\"
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 .\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 .\" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 .\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 .\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 .\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 .\" %%%LICENSE_END
24 .\"
25 .TH program_invocation_name 3 2026-02-08 "Linux man-pages 6.18"
26 .SH NAME
27 program_invocation_name, program_invocation_short_name \- \
28 obtain name used to invoke calling program
29 .SH LIBRARY
30 Standard C library
31 .RI ( libc ,\~ \-lc )
32 .SH SYNOPSIS
33 .nf
34 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
35 .B #include <errno.h>
36 .P
37 .BI "extern char *" program_invocation_name ;
38 .BI "extern char *" program_invocation_short_name ;
39 .fi
40 .SH DESCRIPTION
41 .I program_invocation_name
42 contains the name that was used to invoke the calling program.
43 This is the same as the value of
44 .I argv[0]
45 in
46 .IR main (),
47 with the difference that the scope of
48 .I program_invocation_name
49 is global.
50 .P
51 .I program_invocation_short_name
52 contains the basename component of name that was used to invoke
53 the calling program.
54 That is, it is the same value as
55 .IR program_invocation_name ,
56 with all text up to and including the final slash (/), if any, removed.
57 .P
58 These variables are automatically initialized by the glibc run-time
59 startup code.
60 .SH VERSIONS
61 The Linux-specific
62 .IR /proc/ pid /cmdline
63 file provides access to similar information.
64 .SH STANDARDS
65 GNU.
66 .SH SEE ALSO
67 .BR proc (5)