[parted-devel] Ctrl-C in exception_handler patch

Jonathan duSaint jon at rockgeeks.net
Tue Apr 4 23:22:19 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
here's a patch implementing Ctrl-C in exception_handler, one of the
items on the TODO list,

- --Jon
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEMv+rDjLOpiK8WGARAo4CAJ91BvzgVhrQlFQbekjocvssqP0K7QCgmJc3
AB5NpjSEX6NuPH/bNMCqZKM=
=sAzU
-----END PGP SIGNATURE-----
-------------- next part --------------
Index: parted/ui.c
===================================================================
--- parted/ui.c	(revision 689)
+++ parted/ui.c	(working copy)
@@ -114,6 +114,8 @@
 static struct sigaction sig_fpe;
 static struct sigaction sig_ill;
 
+volatile int got_ctrl_c = 0; /* used in exception_handler */
+
 int
 screen_width ()
 {
@@ -210,6 +212,7 @@
 static void
 sigint_handler (int signum, siginfo_t* info, void *ucontext)
 {
+    got_ctrl_c = 1;
     sigaction (SIGINT, &sig_int, NULL);
     reset_env (0);
 }
@@ -439,8 +442,16 @@
 	if (opt_script_mode)
 		return PED_EXCEPTION_UNHANDLED;
 
+	got_ctrl_c = 0;
+
 	do {
 		opt = command_line_get_ex_opt ("", ex->options);
-	} while (opt == PED_EXCEPTION_UNHANDLED && isatty (0));
+	} while (opt == PED_EXCEPTION_UNHANDLED && isatty (0) && !got_ctrl_c);
+
+	if (got_ctrl_c) {
+                got_ctrl_c = 0;
+		opt = PED_EXCEPTION_UNHANDLED;
+	}
+
 	return opt;
 }


More information about the parted-devel mailing list