From: Davidlohr Bueso Date: Sun, 20 May 2012 16:11:21 +0000 (+0200) Subject: fdisk: add an quit/exit handling function X-Git-Tag: v2.22-rc1~377 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=365f01fcdf1c8bd8b4d096ab20c6259e69a9a749;p=thirdparty%2Futil-linux.git fdisk: add an quit/exit handling function Signed-off-by: Davidlohr Bueso --- 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;