@@ -66,21 +66,19 @@ promptformore(void)
6666 struct termios ntty ;
6767
6868 if (first ) {
69- if (ioctl (0 , TCGETA , & otty ) < 0 ) {
70- fprintf (stderr , "%s: TCGETA ioctl failed: %s\n" , pmGetProgname (),
69+ if (tcgetattr (0 , & otty ) == -1 ) {
70+ fprintf (stderr , "%s: tcgetattr failed: %s\n" , pmGetProgname (),
7171 osstrerror ());
7272 exit (1 );
7373 }
7474 first = 0 ;
7575 }
7676
7777 /* put terminal into raw mode so we can read input immediately */
78- memcpy (& ntty , & otty , sizeof (struct termios ));
79- ntty .c_cc [VMIN ] = 1 ;
80- ntty .c_cc [VTIME ] = 1 ;
81- ntty .c_lflag &= ~(ICANON | ECHO );
82- if (ioctl (0 , TCSETAW , & ntty ) < 0 ) {
83- fprintf (stderr , "%s: TCSETAW ioctl failed: %s\n" , pmGetProgname (),
78+ ntty = otty ;
79+ cfmakeraw (& ntty );
80+ if (tcsetattr (0 , TCSAFLUSH , & ntty ) == -1 ) {
81+ fprintf (stderr , "%s: tcsetattr failed: %s\n" , pmGetProgname (),
8482 osstrerror ());
8583 exit (1 );
8684 }
@@ -122,8 +120,8 @@ promptformore(void)
122120
123121reset_tty :
124122#ifdef HAVE_TERMIOS_H
125- if (ioctl (0 , TCSETAW , & otty ) < 0 ) {
126- fprintf (stderr , "%s: reset TCSETAW ioctl failed: %s\n" , pmGetProgname (),
123+ if (tcsetattr (0 , TCSAFLUSH , & otty ) == -1 ) {
124+ fprintf (stderr , "%s: reset tcsetattr failed: %s\n" , pmGetProgname (),
127125 osstrerror ());
128126 exit (1 );
129127 }
0 commit comments