From 7be207277b18b938385a3c45fa6d098cc9e63adf Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 7 Nov 2012 11:09:17 +0200 Subject: [PATCH] bmap-flasher: act on KeyboardInterrupt When one pressess Ctrl-C, the program hands for several minutes and does not exit. The reason is that the kernel synchronized the block device on the last close. Let's at least print a message to the user and tell that there is no need to worry. Change-Id: I61368dddf697161c2a47012c5f9e2c96b74ef273 Signed-off-by: Artem Bityutskiy --- bmap-flasher | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/bmap-flasher b/bmap-flasher index 97e349b..6bec13d 100755 --- a/bmap-flasher +++ b/bmap-flasher @@ -119,17 +119,25 @@ def main(): % (args.bdev, args.bmap)) try: - flasher.write(False, not args.no_verify) - except BmapFlasher.Error as err: - log.error(str(err)) - raise SystemExit(1) - - # Synchronize the block device - log.info("synchronizing block device '%s'" % args.bdev) - try: - flasher.sync() - except BmapFlasher.Error as err: - log.error(str(err)) + try: + flasher.write(False, not args.no_verify) + except BmapFlasher.Error as err: + log.error(str(err)) + raise SystemExit(1) + + # Synchronize the block device + log.info("synchronizing block device '%s'" % args.bdev) + try: + flasher.sync() + except BmapFlasher.Error as err: + log.error(str(err)) + raise SystemExit(1) + except KeyboardInterrupt: + log.error("the program is interrupted") + log.warning("do not panic if the program may not finish immediately, " \ + "just wait") + log.warning("reason: this is the Linux kernel behavior - it " \ + "synchronizes the block device") raise SystemExit(1) flashing_time = time.time() - start_time -- 2.7.4