[glib: 1/2] gio-tool-mount: Return early on fgets EOF
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gio-tool-mount: Return early on fgets EOF
- Date: Tue, 6 Sep 2022 17:22:16 +0000 (UTC)
commit a0e71ff86ff0511a2a58cb8a8fca49b9ac8dbd88
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Tue Aug 30 16:10:04 2022 +0200
gio-tool-mount: Return early on fgets EOF
As per commit a5390002 we're exiting with error in case fgets failed,
however it could also fail because of EOF (like on ^D), so in such case
we can just return early treating it as a non-error.
Otherwise still exit with error.
Fixes: #2737
gio/gio-tool-mount.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gio/gio-tool-mount.c b/gio/gio-tool-mount.c
index 4d4a45092e..93575c9f39 100644
--- a/gio/gio-tool-mount.c
+++ b/gio/gio-tool-mount.c
@@ -113,7 +113,15 @@ prompt_for (const char *prompt, const char *default_value, gboolean echo)
#endif
if (!fgets (data, sizeof (data), stdin))
- g_error ("Failed to read from standard input");
+ {
+ if (feof (stdin))
+ {
+ g_print ("\n");
+ return NULL;
+ }
+
+ g_error ("Failed to read from standard input");
+ }
#ifdef HAVE_TERMIOS_H
if (restore_flags)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]