public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it
@ 2018-05-28 10:39 Li Wang
  2018-05-29  7:03 ` Xiao Yang
  0 siblings, 1 reply; 6+ messages in thread
From: Li Wang @ 2018-05-28 10:39 UTC (permalink / raw)
  To: ltp

To fix this error:
  tst_test.c:1015: INFO: Timeout per run is 0h 50m 00s
  pty02.c:42: BROK: tcsetattr() failed: EINVAL

POSIX.1 General description:
  Changes the attributes associated with a terminal. New attributes are
  specified with a termios control structure. Programs should always
  issue a tcgetattr() first, modify the desired fields, and then issue
  a tcsetattr(). tcsetattr() should never be issued using a termios
  structure that was not obtained using tcgetattr(). tcsetattr() should
  use only a termios structure that was obtained by tcgetattr().

Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/pty/pty02.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/pty/pty02.c b/testcases/kernel/pty/pty02.c
index fd3d26b..0cedca8 100644
--- a/testcases/kernel/pty/pty02.c
+++ b/testcases/kernel/pty/pty02.c
@@ -31,13 +31,18 @@
 
 static void do_test(void)
 {
-	struct termios io = { .c_lflag = EXTPROC | ICANON };
+	struct termios io;
 	int ptmx, pts;
 	char c = 'A';
 	int nbytes;
 
 	ptmx = SAFE_OPEN("/dev/ptmx", O_WRONLY);
 
+	if (tcgetattr(ptmx, &io) != 0)
+		tst_brk(TBROK | TERRNO, "tcgetattr() failed");
+
+	io.c_lflag = EXTPROC | ICANON;
+
 	if (tcsetattr(ptmx, TCSANOW, &io) != 0)
 		tst_brk(TBROK | TERRNO, "tcsetattr() failed");
 
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-08-16  7:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-28 10:39 [LTP] [PATCH] pty: using tcgetattr() to get attributes before re-setting it Li Wang
2018-05-29  7:03 ` Xiao Yang
2018-05-30  9:52   ` Li Wang
2018-08-15 10:50     ` Cyril Hrubis
2018-08-16  4:49       ` Li Wang
2018-08-16  7:58         ` Li Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox