A little help plz~

Hi, I am new to QNX and I got a weird problem when I run the code below:

//It is suppose to switch the stdin into raw mode
char get_one_char(){
struct termios termios_p;
char c=0;

if(tcgetattr(STDIN_FILENO, &termios_p ) ){
return(0);
}
termios_p.c_cc[VMIN] = 1;
termios_p.c_cc[VTIME] = 0;
termios_p.c_lflag &= ~(ECHO|ICANON|ECHOE|ECHOK|ECHONL);
termios_p.c_oflag &= ~OPOST;
tcsetattr(STDIN_FILENO, TCSADRAIN, &termios_p );
tcflush(STDIN_FILENO, TCIFLUSH);
c = getchar();
termios_p.c_lflag |= (ECHO|ICANON|ISIG|ECHOE|ECHOK|ECHONL);
termios_p.c_oflag |= OPOST;
tcsetattr(STDIN_FILENO, TCSADRAIN, &termios_p );
return c;
}

The code are included in a child thread.
After I created the thread, I try to print something in the main thread.
while(1)
{
printf(“testing…\n”);
}

The printing on the screen is:

testing…
_______testing…
______________testing…
_____________________testing…

(the underlines mean space)

I think it must be the setting problem in the termios but I can’t figure it out where it the problem.

Thanks.

The OPOST flag means you are clearing post process thus the /n does get translated to a /r/n. Hence the cursor only goes down but doesn’t go back to the beginning of the line.

[quote=“mario”]
The OPOST flag means you are clearing post process thus the /n does get translated to a /r/n. Hence the cursor only goes down but doesn

Thanks mario. The problem is that even I commented the OPOST code now. The printing is still the way as it was. Can I modify this flag by other means? Where can I locate this flag? Use stty?

Thanks

Hi, Mario, I’ve solved the problem, use stty. Thanks a lot!!