From patchwork Thu Jul 20 07:47:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Schmoll X-Patchwork-Id: 9854061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 16E5060392 for ; Thu, 20 Jul 2017 07:50:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 090FF281C3 for ; Thu, 20 Jul 2017 07:50:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1F6F2874B; Thu, 20 Jul 2017 07:50:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A980281C3 for ; Thu, 20 Jul 2017 07:50:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dY6Bn-0006SR-4x; Thu, 20 Jul 2017 07:48:03 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dY6Bl-0006SL-TS for xen-devel@lists.xenproject.org; Thu, 20 Jul 2017 07:48:02 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 30/58-03406-13060795; Thu, 20 Jul 2017 07:48:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRWlGSWpSXmKPExsVyMbThiK5BQkG kwfJVOhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bUu7dZCxbxVXxauYS5gfEkdxcjF4eQwAxG iW23L7KAOCwCl1gk5jyawwbiSAi8Y5G4cngFaxcjB5CTJnHos0YXIyeQWS3x8MVRFhBbSEBT4 kt3FyPEpHlMEk/+HWYDSbAJGEjMXnmRGcQWEVCSuLdqMhOIzSyQING06BpYs7CAj8TRE/PZQW wWAVWJFd/ugO3iFbCT6N7JC7FLXmJX20XWCYx8CxgZVjFqFKcWlaUW6Rob6SUVZaZnlOQmZub oGhqY6eWmFhcnpqfmJCYV6yXn525iBAYKAxDsYDy9LvAQoyQHk5IoL0tgQaQQX1J+SmVGYnFG fFFpTmrxIUYZDg4lCd5lcUA5waLU9NSKtMwcYMjCpCU4eJREeE+ApHmLCxJzizPTIVKnGC05r lxZ94WJY8qB7UDy1YT/35iEWPLy81KlxHlngjQIgDRklObBjYPF1SVGWSlhXkagA4V4ClKLcj NLUOVfMYpzMCoJ814AmcKTmVcCt/UV0EFMQAc9cgM7qCQRISXVwOgfU/agRmKJXbPmL34X/+C kr8GrPgSKMi20V0s9Wmjz7VGOaCzD82svpm3/NoXzQt7yl74TExx/133X23HlVUr5RCaRnzxt YgFi+i5LP0V4py43vaY+y+GB3jeL+FnLLMSEb6lmr+lfovJU7WHgtJMRFzkCbxdJX5Ldzd+xK 2fJDe+AZR/C3ZVYijMSDbWYi4oTAaPj4b6mAgAA X-Env-Sender: eggi.innovations@gmail.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1500536880!103418925!1 X-Originating-IP: [209.85.128.196] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36873 invoked from network); 20 Jul 2017 07:48:00 -0000 Received: from mail-wr0-f196.google.com (HELO mail-wr0-f196.google.com) (209.85.128.196) by server-7.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 20 Jul 2017 07:48:00 -0000 Received: by mail-wr0-f196.google.com with SMTP id o33so2189782wrb.1 for ; Thu, 20 Jul 2017 00:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Jp6MVaV+6Eo6k3vUH85l9PtNg+pSGkJCDFi1uKOfYpw=; b=sRFunReKUpFQaRXXzg+epAOo0Q1s5kjQYhHnAIKqBtD8BBjEoX4po3glD5RYYlJ3D2 2AL8Gj5b9I+KfadyP5GGzfODT59dhwdsZ6M7EFV6ChyRLoGWGvpSKll55CQtDrj0Esql arUTXHUF2wfEk1wPc7wh1Zy7EKNaCaJ5wzfTMIDIAzT7ngNFdYqBngevrAV3PDZP0Z7z mp2nxI9xYiHxs02rJhA8QoC2lnpGewIgmqmGc+o7GxLkFKQOKoRNo87Oaq+m7E4n+IIY fSFIVLscjhslwIfjbm7ESBuYRd9gJ08mBxyhr1J5BFs9VIsY3PTO3Mu6Jw6Z5LEBWZ5H /i8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Jp6MVaV+6Eo6k3vUH85l9PtNg+pSGkJCDFi1uKOfYpw=; b=iWydSHT+qqbiojypvjsyCG27V0yLA+HG4VLJAC7rXDnv89I7oEfkmgyFV4uXNRRuMd RUsIavnVCplnXOwgqUywwAjo9qw/5oovUSISEk1gQxtaXXvxwSUy2aJwFgO62YYxBdRG TxCxD/TCWj7DunKRUA8Eaa1KZcbu1X04XvR65lleB669jRioBNaLaiTCjoumJSQnYInK jlYbpxWdWfMtHHEMoN8LJJW6PzwWrkTBTTHD55fuA9EjWl+IBAo46a+42okLdNLyeeja 3jybmxZEFfXPLH7ay00dVLi4O3D0DT7gQX36m7bOEubcg3izjGkEKFSYckb9V0Sq31uu BtKA== X-Gm-Message-State: AIVw1127Pw/FaFeYQoRXFD/lYBjNlmhihHwCfHPTfG/KfjS1JC+fNflQ BDZHd3qSA6Gre09p+gBr5Q== X-Received: by 10.223.175.212 with SMTP id y20mr2217506wrd.267.1500536879999; Thu, 20 Jul 2017 00:47:59 -0700 (PDT) Received: from localhost.localdomain (ip-109-47-2-190.web.vodafone.de. [109.47.2.190]) by smtp.gmail.com with ESMTPSA id v8sm5527769wrd.28.2017.07.20.00.47.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jul 2017 00:47:59 -0700 (PDT) From: Felix Schmoll To: xen-devel@lists.xenproject.org Date: Thu, 20 Jul 2017 09:47:48 +0200 Message-Id: <20170720074748.2164-1-eggi.innovations@gmail.com> X-Mailer: git-send-email 2.11.0 Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, Felix Schmoll Subject: [Xen-devel] [PATCH v3] Add option to xenconsole to always forward console input X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently the default behaviour of the xenconsole client is to ignore any input to stdin, unless stdin and stdout are both ttys. The new option allows to manually overwrite this, causing the client to forward input regardless. Signed-off-by: Felix Schmoll Acked-by: Wei Liu Acked-by: Ian Jackson --- Changed since v2: * change name of option from 'pipe' to 'interactive' * extend commit message to include current default handling of stdin * refactor code to avoid introducing a new variable --- tools/console/client/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/console/client/main.c b/tools/console/client/main.c index 977779f034..c340cb7de3 100644 --- a/tools/console/client/main.c +++ b/tools/console/client/main.c @@ -334,6 +334,7 @@ int main(int argc, char **argv) { "num", 1, 0, 'n' }, { "help", 0, 0, 'h' }, { "start-notify-fd", 1, 0, 's' }, + { "interactive", 0, 0, 'i' }, { 0 }, }; @@ -344,9 +345,6 @@ int main(int argc, char **argv) console_type type = CONSOLE_INVAL; bool interactive = 0; - if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) - interactive = 1; - while((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) { switch(ch) { case 'h': @@ -370,6 +368,9 @@ int main(int argc, char **argv) case 's': start_notify_fd = atoi(optarg); break; + case 'i': + interactive = 1; + break; default: fprintf(stderr, "Invalid argument\n"); fprintf(stderr, "Try `%s --help' for more information.\n", @@ -464,7 +465,8 @@ int main(int argc, char **argv) } init_term(spty, &attr); - if (interactive) { + if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) { + interactive = 1; init_term(STDIN_FILENO, &stdin_old_attr); atexit(restore_term_stdin); /* if this fails, oh dear */ }