parted/0055-parted-fix-EOF-and-ctrl-c-handling.patch
Brian C. Lane 0b7af917e2 - Rebase on new upstream master commit cc382c3
- Drop patches incorporated into upstream
- Still adds the various DASD patches
2014-04-08 11:46:37 -07:00

74 lines
2.4 KiB
Diff

From 8ae195863e7d6950cfcc7a067f52e46f295655a7 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 5 Jan 2013 15:13:50 -0500
Subject: [PATCH 55/89] parted: fix EOF and ctrl-c handling
feof() seems to not detect EOF after readline() hits it, so parted went
into an infinite loop prompting for input on EOF. Change test to use the
got_ctrl_c variable instead, which is set when readline hits EOF and
returns NULL. This also makes parted properly exit on ctrl-c.
---
NEWS | 4 ++++
parted/ui.c | 16 ++++++----------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/NEWS b/NEWS
index 50faf4d..a27200b 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ parted: fix EOF and ctrl-c handling. parted used to refuse to exit
+ in response to ctrl-c and would get stuck in an infinite loop
+ prompting for more input when it reached EOF on stdin.
+
libparted: Don't fail to manipulate partitions on dmraid disks that
have other partitions in use.
diff --git a/parted/ui.c b/parted/ui.c
index 22790bb..786deed 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -647,15 +647,7 @@ exception_handler (PedException* ex)
got_ctrl_c = 0;
- do {
- opt = command_line_get_ex_opt ("", ex->options);
- } while (opt == PED_EXCEPTION_UNHANDLED
- && (isatty (0) || pretend_input_tty) && !got_ctrl_c);
-
- if (got_ctrl_c) {
- got_ctrl_c = 0;
- opt = PED_EXCEPTION_UNHANDLED;
- }
+ opt = command_line_get_ex_opt ("", ex->options);
return opt;
}
@@ -900,6 +892,10 @@ command_line_get_word (const char* prompt, const char* def,
command_line_prompt_words (prompt, def, possibilities,
multi_word);
+ if (got_ctrl_c) {
+ got_ctrl_c = 0;
+ return NULL;
+ }
} while (command_line_get_word_count ());
return NULL;
@@ -1581,7 +1577,7 @@ interactive_mode (PedDevice** dev, Command* cmd_list[])
Command* cmd;
while (!command_line_get_word_count ()) {
- if (feof (stdin)) {
+ if (got_ctrl_c) {
putchar ('\n');
return 1;
}
--
1.8.5.3