stat.2: Use lstat() instead of stat()

It's more logical to use lstat() in the example code,
since one can then experiment with sybolic links, and
also the S_IFLNK case can also occur.

Reported-by: Richard Knutsson <richard.knutsson@abelko.se>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2017-10-17 22:58:40 +02:00
parent 9dc4485584
commit 133ca6caab
1 changed files with 3 additions and 3 deletions

View File

@ -634,7 +634,7 @@ or, on some architectures,
.BR newfstatat ().
.SH EXAMPLE
The following program calls
.BR stat ()
.BR lstat ()
and displays selected fields in the returned
.I stat
structure.
@ -657,8 +657,8 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
if (stat(argv[1], &sb) == \-1) {
perror("stat");
if (lstat(argv[1], &sb) == \-1) {
perror("lstat");
exit(EXIT_FAILURE);
}