aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorMateusz Piotrowski <0mp@FreeBSD.org>2021-04-17 21:26:54 +0000
committerMateusz Piotrowski <0mp@FreeBSD.org>2021-04-18 08:20:11 +0000
commit1ffdcdadf61423dd02ddad82fc4f3f6c39090c8c (patch)
treedb7c8488e12e7bb534395633b686a661eda52dae /lib/libc
parent40277af7f23405c276edf02c3ddc8e770a06e3f6 (diff)
downloadsrc-1ffdcdadf61423dd02ddad82fc4f3f6c39090c8c.tar.gz
src-1ffdcdadf61423dd02ddad82fc4f3f6c39090c8c.zip
getprogname.3: Add an example
It shows the difference between getprogname() and argv[0]. Reviewed by: yuripv Approved by: yuripv (src) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27204
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getprogname.328
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/libc/gen/getprogname.3 b/lib/libc/gen/getprogname.3
index 53d39a60526b..f43a7b8c6b69 100644
--- a/lib/libc/gen/getprogname.3
+++ b/lib/libc/gen/getprogname.3
@@ -31,7 +31,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 1, 2001
+.Dd April 18, 2021
.Dt GETPROGNAME 3
.Os
.Sh NAME
@@ -84,6 +84,32 @@ Calling
.Fn setprogname
allows the aforementioned library to learn the program name without
modifications to the start-up code.
+.Sh EXAMPLES
+The following example presents a simple program, which shows the difference
+between
+.Fn getprogname
+and
+.Va "argv[0]" .
+.Bd -literal -offset indent
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char** argv)
+{
+ printf("getprogname(): %s\en", getprogname());
+ printf("argv[0]: %s\en", argv[0]);
+ return (0);
+}
+.Ed
+.Pp
+When compiled and executed (e.g., with
+.Ql ./a.out )
+the output of the program is going to look like this:
+.Bd -literal -offset indent
+getprogname(): a.out
+argv[0]: ./a.out
+.Ed
.Sh SEE ALSO
.Xr err 3 ,
.Xr setproctitle 3