Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aDTdu-0003qD-01 for mharc-grub-devel@gnu.org; Mon, 28 Dec 2015 03:59:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDTdr-0003mv-5X for grub-devel@gnu.org; Mon, 28 Dec 2015 03:59:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDTdn-0007KN-Vm for grub-devel@gnu.org; Mon, 28 Dec 2015 03:58:59 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:55214 helo=prv3-mh.provo.novell.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDTdn-0007Jn-PD for grub-devel@gnu.org; Mon, 28 Dec 2015 03:58:55 -0500 Received: from linux-dsax.tai.apac.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (TLS encrypted); Mon, 28 Dec 2015 01:58:38 -0700 Date: Mon, 28 Dec 2015 16:47:14 +0800 From: Michael Chang To: Andrei Borzenkov Subject: Re: [PATCH] emu: fix unusable terminal after exit Message-ID: <20151228084714.GD17636@linux-dsax.tai.apac.novell.com> Mail-Followup-To: Andrei Borzenkov , The development of GNU GRUB References: <20151223094945.GA17566@linux-dsax.tai.apac.novell.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="NzB8fVQJ5HfG6fxh" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 137.65.250.26 Cc: The development of GNU GRUB X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 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, 28 Dec 2015 08:59:00 -0000 --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Dec 23, 2015 at 02:45:20PM +0300, Andrei Borzenkov wrote: > On Wed, Dec 23, 2015 at 12:49 PM, Michael Chang wrote: > > The grub-emu's grub_exit function will exit immediately without any > > housekeeping work for restoring terminal settings and leaves unusable > > terminal in the end. Fix the problem by calling grub_reboot to allow > > doing the housekeeping work and restoring the terminal settings. > > > > --- > > grub-core/commands/minicmd.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c > > index a3a1182..63ffeb5 100644 > > --- a/grub-core/commands/minicmd.c > > +++ b/grub-core/commands/minicmd.c > > @@ -181,7 +181,11 @@ grub_mini_cmd_exit (struct grub_command *cmd __attribute__ ((unused)), > > int argc __attribute__ ((unused)), > > char *argv[] __attribute__ ((unused))) > > { > > +#if defined (GRUB_MACHINE_EMU) > > + grub_reboot (); > > +#else > > grub_exit (); > > +#endif > > /* Not reached. */ > > } > > > > No, please. Just make EMU grub_exit do the right thing (assuming it is > the right thing :) I'm not sure it's right thing either, that's why I was not trying to modify grub_exit because EMU shares it with utils, as souce file grub-core/kern/emu/misc.c is also part of libgrubkern.a used also in other platforms. But anyway, please check attached patch again, which tries to separate the EMU's grub_exit with the one in libgrubkern.a. Thanks. --NzB8fVQJ5HfG6fxh Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="grub-exit.diff" diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index 4b50913..221aa12 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -66,6 +66,12 @@ grub_reboot (void) } void +grub_exit (void) +{ + grub_reboot (); +} + +void grub_machine_init (void) { } diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index bb606da..9353fa7 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -134,11 +134,13 @@ xasprintf (const char *fmt, ...) } #endif +#if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) void grub_exit (void) { exit (1); } +#endif grub_uint64_t grub_get_time_ms (void) --NzB8fVQJ5HfG6fxh--