tty-handler: use simpler open in non-blocking mode

Currently, we're opening the tty file descriptor in blocking mode, then
switching to non-blocking mode with fcntl(F_SETFL, F_NDELAY);

[and F_NDELAY == O_NDELAY == O_NONBLOCK ]

This change just opens with O_NONBLOCK instead.

Change-Id: I414ebec632008d65dec87d956d5a0ac1a46ec837
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/tty-handler.c b/tty-handler.c
index b9a5afb..5e36ee6 100644
--- a/tty-handler.c
+++ b/tty-handler.c
@@ -171,7 +171,7 @@
 	const char *tty_name;
 	const char *tty_baud;
 	char *tty_path;
-	int rc, flags;
+	int rc;
 
 	tty_name = config_get_value(config, "local-tty");
 	if (!tty_name)
@@ -181,7 +181,7 @@
 	if (!rc)
 		return -1;
 
-	th->fd = open(tty_path, O_RDWR);
+	th->fd = open(tty_path, O_RDWR | O_NONBLOCK);
 	if (th->fd < 0) {
 		warn("Can't open %s; disabling local tty", tty_name);
 		free(tty_path);
@@ -190,11 +190,6 @@
 
 	free(tty_path);
 
-	/* initial tty setup */
-	flags = fcntl(th->fd, F_GETFL, 0);
-	flags |= FNDELAY;
-	fcntl(th->fd, F_SETFL, flags);
-
 	tty_baud = config_get_value(config, "local-tty-baud");
 	if (tty_baud != NULL)
 		if (set_terminal_baud(th, tty_name, tty_baud) != 0)