LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   xTerm on pseudo terminal hast no output (http://www.linuxquestions.org/questions/linux-software-2/xterm-on-pseudo-terminal-hast-no-output-815880/)

Semo 06-23-2010 06:44 AM

xTerm on pseudo terminal hast no output
 
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.

Semo 06-24-2010 06:07 AM

push !
More than 70 views and not one idea... kind of depressing :-(
This cant be as hard as it looks.

hmmpf .... continue searching for an answer....

frieza 06-24-2010 01:17 PM

are you writing using the ncurses api?

Semo 06-25-2010 04:09 AM

No I don't use ncurses and I wont use it because its like breaking a nut with a sledgehammer. I read, that the most people use the raw mode but I can't find an example or anything about the use of the canonical mode. This feature is like a unloved child. Hard to figure out why.

Semo 06-30-2010 11:29 AM

another push!
Since I'm searching for a solution I think nobody ever uses this feature. I hope somebody has any idea. But I guess nobody has....

:-(


All times are GMT -5. The time now is 10:04 AM.