diff mbox

[v3] Add option to xenconsole to always forward console input

Message ID 20170720074748.2164-1-eggi.innovations@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Felix Schmoll July 20, 2017, 7:47 a.m. UTC
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 <eggi.innovations@gmail.com>

---
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(-)

Comments

Wei Liu July 20, 2017, 8:12 a.m. UTC | #1
On Thu, Jul 20, 2017 at 09:47:48AM +0200, Felix Schmoll wrote:
> 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 <eggi.innovations@gmail.com>


Acked-by: Wei Liu <wei.liu2@citrix.com>

Note to self: add "xenconsole: " prefix to subject while committing.
Ian Jackson July 20, 2017, 10:10 a.m. UTC | #2
Felix Schmoll writes ("[PATCH v3] Add option to xenconsole to always forward console input"):
> 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 <eggi.innovations@gmail.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Wei Liu July 20, 2017, 4:37 p.m. UTC | #3
On Thu, Jul 20, 2017 at 09:47:48AM +0200, Felix Schmoll wrote:
> 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 <eggi.innovations@gmail.com>

Queued.

I believe this is your first patch to be committed to xen.git, so
congratulations!
diff mbox

Patch

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 */
 	}