Hello,
I hope this is the right forum for my issue.
I'm writing a programm in c++ and want a interactiv way to communicate with it. The program opens a pseudo terminal(pt) in read/write mode and after that it forcs and opens a xTerm instance with the -Sccn option.
After playing around with the ps options like ICANON and ECHO I got a running example in raw mode but then I have to implement the line discipline and the erasing characters an so on on my self.
I don't want to do this :-)
What I want is to get a Xterm/pt connection to my application where only line will be transmitted and signals and erase chars are processed.
At this time. I have following situation:
Turned ICANON on.
My applications sends a couple of chars to the pt-master (ptm). Nothing will be printed on the xTerm.
If I type some chars into the xTerm window, my application receives them. (char after char ... no CR or else) The chars I typed not even printed in the xTerm window.
If nothing is to read the read() funktion returns -1.
Here are the code of the opening and configurating the pt.
Code:
tty_master_fd = open ("/dev/ptmx", O_RDWR | O_NOCTTY| O_NDELAY); //open Master for pseudo terminal
grantpt(tty_master_fd); //necessary for pseudo terminal, grant the new terminal the right of the opening process
unlockpt(tty_master_fd); //necessary for pseudo terminal, unlocks the terminal so other programs can read/write to it
tty_slavename = ptsname(tty_master_fd); //read path for slave side of the pseudo terminal
int tty_slave_fd = open(tty_slavename, O_RDWR | O_NOCTTY | O_NDELAY); //open slave side of the terminal
...
struct termios termInfo; //create new register set
tcgetattr(tty_slave_fd, &termInfo);
termInfo.c_lflag &= ~(ECHOPRT);
termInfo.c_lflag |= (ICANON | ECHO | ECHOE | ECHOKE | ECHONL | CLOCAL );
termInfo.c_oflag |= ONLRET; //transform new line characters to carriage return
tcsetattr( tty_slave_fd, TCSANOW, &termInfo ); //set changes to the control registers now
tcsetattr(tty_master_fd, TCSANOW, &termInfo ); // don't know whitch side of the pt I have to control
...
int terminal= fork();
if(terminal==0)
{
//cout<<args<<endl; //for debug
termPID = execvp("xterm",arg); //start the xterm
}
I hope somebody can give me a hint where my error is.