svn commit: trunk/busybox/miscutils

pgf at busybox.net pgf at busybox.net
Wed Apr 23 15:31:30 UTC 2008


Author: pgf
Date: 2008-04-23 08:31:29 -0700 (Wed, 23 Apr 2008)
New Revision: 21813

Log:
delay reconfig of input tty until target device has been both opened
and configured correctly.


Modified:
   trunk/busybox/miscutils/microcom.c


Changeset:
Modified: trunk/busybox/miscutils/microcom.c
===================================================================
--- trunk/busybox/miscutils/microcom.c	2008-04-23 15:27:15 UTC (rev 21812)
+++ trunk/busybox/miscutils/microcom.c	2008-04-23 15:31:29 UTC (rev 21813)
@@ -96,14 +96,6 @@
 	// error exit code if we fail to open the device
 	signalled = 1;
 
-	// put stdin to "raw mode" (if stdin is a TTY),
-	// handle one character at a time
-	if (isatty(STDIN_FILENO)) {
-		xget1(STDIN_FILENO, &tio, &tio0);
-		if (xset1(STDIN_FILENO, &tio, "stdin"))
-			goto done;
-	}
-
 	// open device
 	sfd = open_or_warn(argv[0], O_RDWR | O_NOCTTY | O_NONBLOCK);
 	if (sfd < 0)
@@ -112,12 +104,19 @@
 
 	// put device to "raw mode"
 	xget1(sfd, &tio, &tiosfd);
-//	tio.c_cflag |= (CREAD|HUPCL); // we just bail out on any device error
 	// set device speed
 	cfsetspeed(&tio, tty_value_to_baud(speed));
 	if (xset1(sfd, &tio, argv[0]))
-		goto restore0_and_done;
+		goto done;
 
+	// put stdin to "raw mode" (if stdin is a TTY),
+	// handle one character at a time
+	if (isatty(STDIN_FILENO)) {
+		xget1(STDIN_FILENO, &tio, &tio0);
+		if (xset1(STDIN_FILENO, &tio, "stdin"))
+			goto done;
+	}
+
 	// main loop: check with poll(), then read/write bytes across
 	pfd[0].fd = sfd;
 	pfd[0].events = POLLIN;
@@ -169,7 +168,6 @@
 	// restore device mode
 	tcsetattr(sfd, TCSAFLUSH, &tiosfd);
 
-restore0_and_done:
 	if (isatty(STDIN_FILENO))
 		tcsetattr(STDIN_FILENO, TCSAFLUSH, &tio0);
 




More information about the busybox-cvs mailing list