From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933188AbbLHOda (ORCPT ); Tue, 8 Dec 2015 09:33:30 -0500 Received: from mga03.intel.com ([134.134.136.65]:35934 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755329AbbLHOd2 (ORCPT ); Tue, 8 Dec 2015 09:33:28 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,400,1444719600"; d="scan'208";a="856456964" From: Daniel Baluta To: rusty@rustcorp.com.au, lguest@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, daniel.baluta@intel.com Subject: [PATCH] tools/lguest: Don't bork the terminal in case of wrong args Date: Tue, 8 Dec 2015 16:35:32 +0200 Message-Id: <1449585332-12360-1-git-send-email-daniel.baluta@intel.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Running lguest without arguments or with a wrong argument name borks the terminal, because the cleanup handler is set up too late in the initialization process. Signed-off-by: Daniel Baluta --- tools/lguest/lguest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lguest/lguest.c b/tools/lguest/lguest.c index 80159e6..b7b9c6f 100644 --- a/tools/lguest/lguest.c +++ b/tools/lguest/lguest.c @@ -3266,6 +3266,9 @@ int main(int argc, char *argv[]) } } + /* If we exit via err(), this kills all the threads, restores tty. */ + atexit(cleanup_devices); + /* We always have a console device, and it's always device 1. */ setup_console(); @@ -3363,9 +3366,6 @@ int main(int argc, char *argv[]) /* Ensure that we terminate if a device-servicing child dies. */ signal(SIGCHLD, kill_launcher); - /* If we exit via err(), this kills all the threads, restores tty. */ - atexit(cleanup_devices); - /* If requested, chroot to a directory */ if (chroot_path) { if (chroot(chroot_path) != 0) -- 1.9.1