From: Davidlohr Bueso <dave@gnu.org>
To: Karel Zak <kzak@redhat.com>, Petr Uzel <petr.uzel@suse.cz>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: [PATCH 1/6] fdisk: add an quit/exit handling function
Date: Sun, 20 May 2012 18:11:21 +0200 [thread overview]
Message-ID: <1337530281.2677.12.camel@offbook> (raw)
From: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
fdisk/fdisk.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 3f83297..2f3c119 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;
--
1.7.4.1
reply other threads:[~2012-05-20 16:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337530281.2677.12.camel@offbook \
--to=dave@gnu.org \
--cc=kzak@redhat.com \
--cc=petr.uzel@suse.cz \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox