Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the TTY of a new xterm 2

Status
Not open for further replies.

jstreich

Programmer
Apr 20, 2002
1,067
US
Is there a nice way of getting the TTY of a new xterm on it's creation semi-auto-magically and suppressing the xterms initial prompts? I am trying to write to the window from C/C++, but I need the pts number of the TTY... So how do I find out what TTY is the new one?
 
Try to grab the output of the stty command

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Rather than trying to start an xterm and write from it externally, have the xterm run whatever you need as a subprocess, then the output of stty or tty is available to it.
 
I meant to say:

Rather than trying to start an xterm and write TO it externally, have the xterm run whatever you need as a subprocess, then the output of stty or tty is available to it.


 
indeed I think I have a way to do it by grabbing the tty... But it has a couple of problems that I have yet to solve. The biggest making the new term window sleep for the length of the program execution.

Eric, this is a good idea, but I'm not sure how I'd do it... I'd have to write two programs instead of one, and then get the child process to talk to it's parent using named pipes or some other technology (without talking to other instances of the program).

I think I'm on to something with these suggestions... thank you, both (start to each of you).
 
You might look at the source code for xconsole (part of the X11 code base) and see how they do it.

BTW, using named pipes or sockets to talk in a client server fashion would save a lot of problems that may crop up if the xterm is closed. The 2nd program could be as simple as "cat /var/run/myfifo". You could put that in a script and specify that as the shell the xterm should run, or use the -e switch.

Alternatively, it's not too difficult to code up a scrolling text window in X and skip the xterm completely, the code is all there for the taking.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top