* [patch] inotify.7: Merge late perror() into fprintf()
@ 2020-01-20 16:58 Nick Shipp
2020-01-21 19:46 ` Michael Kerrisk (man-pages)
0 siblings, 1 reply; 2+ messages in thread
From: Nick Shipp @ 2020-01-20 16:58 UTC (permalink / raw)
To: mtk.manpages; +Cc: linux-man
fprintf may have overridden errno before perror could print it in this
example.
---
man7/inotify.7 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/man7/inotify.7 b/man7/inotify.7
index c052acfe6..995a3116f 100644
--- a/man7/inotify.7
+++ b/man7/inotify.7
@@ -1045,8 +1045,8 @@ main(int argc, char* argv[])
wd[i] = inotify_add_watch(fd, argv[i],
IN_OPEN | IN_CLOSE);
if (wd[i] == \-1) {
- fprintf(stderr, "Cannot watch '%s'\en", argv[i]);
- perror("inotify_add_watch");
+ fprintf(stderr, "Cannot watch '%s': %s\en",
+ argv[i], strerror(errno));
exit(EXIT_FAILURE);
}
}
--
2.25.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] inotify.7: Merge late perror() into fprintf()
2020-01-20 16:58 [patch] inotify.7: Merge late perror() into fprintf() Nick Shipp
@ 2020-01-21 19:46 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-01-21 19:46 UTC (permalink / raw)
To: Nick Shipp; +Cc: mtk.manpages, linux-man
Hello Nick,
On 1/20/20 5:58 PM, Nick Shipp wrote:
> fprintf may have overridden errno before perror could print it in this
> example.
Thanks. Patch applied.
Cheers,
Michael
> ---
> man7/inotify.7 | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/man7/inotify.7 b/man7/inotify.7
> index c052acfe6..995a3116f 100644
> --- a/man7/inotify.7
> +++ b/man7/inotify.7
> @@ -1045,8 +1045,8 @@ main(int argc, char* argv[])
> wd[i] = inotify_add_watch(fd, argv[i],
> IN_OPEN | IN_CLOSE);
> if (wd[i] == \-1) {
> - fprintf(stderr, "Cannot watch '%s'\en", argv[i]);
> - perror("inotify_add_watch");
> + fprintf(stderr, "Cannot watch '%s': %s\en",
> + argv[i], strerror(errno));
> exit(EXIT_FAILURE);
> }
> }
> --
> 2.25.0
>
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-21 19:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 16:58 [patch] inotify.7: Merge late perror() into fprintf() Nick Shipp
2020-01-21 19:46 ` Michael Kerrisk (man-pages)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).