Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NWy36-0000d8-U9 for mharc-grub-devel@gnu.org; Mon, 18 Jan 2010 15:18:08 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWy35-0000cC-3Q for grub-devel@gnu.org; Mon, 18 Jan 2010 15:18:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWy33-0000bW-Pm for grub-devel@gnu.org; Mon, 18 Jan 2010 15:18:06 -0500 Received: from [199.232.76.173] (port=51274 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWy33-0000bO-Kl for grub-devel@gnu.org; Mon, 18 Jan 2010 15:18:05 -0500 Received: from stallman.rootnode.net ([89.248.165.10]:53268) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NWy33-0008I9-8q for grub-devel@gnu.org; Mon, 18 Jan 2010 15:18:05 -0500 Received: from athlon.localnet (chello087207144242.chello.pl [87.207.144.242]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by stallman.rootnode.net (Exchange) with ESMTP id 3B45D5FB1B for ; Mon, 18 Jan 2010 21:17:33 +0100 (CET) From: Szymon Janc To: The development of GNU GRUB Date: Mon, 18 Jan 2010 21:17:41 +0100 User-Agent: KMail/1.12.4 (Linux/2.6.32-trunk-686; KDE/4.3.4; i686; ; ) MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_lHMVLKyHLCGl9e1" Message-Id: <201001182117.41329.szymon@janc.net.pl> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] make 'sleep --interruptible 0' interruptible X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2010 20:18:07 -0000 --Boundary-00=_lHMVLKyHLCGl9e1 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello, Attached patch makes sleep -i 0 "interruptible". It allows to have 0 sleep yet selectable multiboot config i.e. if sleep --interruptible 0 ; then set timeout=0 fi -- Szymon K. Janc szymon@janc.net.pl // GG: 1383435 --Boundary-00=_lHMVLKyHLCGl9e1 Content-Type: text/x-patch; charset="UTF-8"; name="sleep.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="sleep.diff" --- grub_orig/grub2-1.98~experimental.20100111.1/commands/sleep.c 2010-01-11 20:01:15.000000000 +0100 +++ grub/grub2-1.98~experimental.20100111.1/commands/sleep.c 2010-01-18 20:37:56.107189595 +0100 @@ -44,19 +44,26 @@ grub_printf ("%d ", n); } +static int +do_check_key_press (void) +{ + return (grub_checkkey () >= 0 + && GRUB_TERM_ASCII_CHAR (grub_getkey ()) == GRUB_TERM_ESC); +} + /* Based on grub_millisleep() from kern/generic/millisleep.c. */ static int grub_interruptible_millisleep (grub_uint32_t ms) { grub_uint64_t start; - start = grub_get_time_ms (); - + while (grub_get_time_ms () - start < ms) - if (grub_checkkey () >= 0 && - GRUB_TERM_ASCII_CHAR (grub_getkey ()) == GRUB_TERM_ESC) + { + if (do_check_key_press ()) return 1; - + } + return 0; } @@ -64,18 +71,20 @@ grub_cmd_sleep (grub_extcmd_t cmd, int argc, char **args) { struct grub_arg_list *state = cmd->state; - int n; + unsigned long n; if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing operand"); n = grub_strtoul (args[0], 0, 10); + if (n == ~0UL) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "incorrect value"); + if (n == 0) - { - /* Either `0' or broken input. */ - return 0; - } + { + return (state[1].set && do_check_key_press ()); + } pos = grub_term_save_pos (); --Boundary-00=_lHMVLKyHLCGl9e1--