From 365f01fcdf1c8bd8b4d096ab20c6259e69a9a749 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Sun, 20 May 2012 18:11:21 +0200 Subject: [PATCH] fdisk: add an quit/exit handling function Signed-off-by: Davidlohr Bueso --- fdisk/fdisk.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 3f832977c1..2f3c11900b 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -1810,6 +1810,13 @@ move_begin(int i) { } } +static void __attribute__ ((__noreturn__)) handle_quit(void) +{ + close(fd); + printf("\n"); + exit(EXIT_SUCCESS); +} + static void expert_command_prompt(void) { @@ -1875,9 +1882,7 @@ expert_command_prompt(void) x_list_table(0); break; case 'q': - close(fd); - printf("\n"); - exit(0); + handle_quit(); case 'r': return; case 's': @@ -2064,9 +2069,7 @@ static void command_prompt(void) list_table(0); break; case 'q': - close(fd); - printf("\n"); - exit(0); + handle_quit(); case 's': create_sunlabel(); break; -- 2.47.3