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 | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS index 98f7c6e..5b76b4d 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..7df12e6 100644 --- a/parted/ui.c +++ b/parted/ui.c @@ -900,6 +900,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 +1585,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.1.2