Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 06-23-2010, 06:44 AM   #1
LQ Newbie
Registered: Jun 2010
Posts: 6

Rep: Reputation: 0
xTerm on pseudo terminal hast no output

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.

		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();
			//cout<<args<<endl;	//for debug
			termPID = execvp("xterm",arg);	//start the xterm
I hope somebody can give me a hint where my error is.
Old 06-24-2010, 06:07 AM   #2
LQ Newbie
Registered: Jun 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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....
Old 06-24-2010, 01:17 PM   #3
Senior Member
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,227

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
are you writing using the ncurses api?
Old 06-25-2010, 04:09 AM   #4
LQ Newbie
Registered: Jun 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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.
Old 06-30-2010, 11:29 AM   #5
LQ Newbie
Registered: Jun 2010
Posts: 6

Original Poster
Rep: Reputation: 0
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....



c++, pseudo, pts, terminal, xterm

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
pseudo terminal problem ghostwhowalks Programming 3 01-13-2010 11:44 PM
font in pseudo terminal crs_zxf Linux - Newbie 7 07-26-2009 09:38 PM
Error opening terminal: xterm Terminal type "xterm" unknown Pscylo Slackware 10 04-17-2009 07:33 AM
Pseudo-Terminal means? Marty21 Linux - Software 1 01-28-2009 03:53 PM
Pseudo Terminal Problems ailiez Programming 2 02-09-2004 02:58 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration