Results 1 to 5 of 5
hi i want to know hw to create a new terminal from a working terminal.The situation is like i want to create another terminal where i could run my command ...
- 06-04-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 2
how to create a new terminal from an existing one
hi i want to know hw to create a new terminal from a working terminal.The situation is like i want to create another terminal where i could run my command line interface..In the first terminal i was initializing my actual module.This module includes a CLI which i had integrated,but it is also on the same terminal.I am spawning a new thread for CLI and it is using the same address space of the above module.So CLI is not a diff process.So is it possible for me to create another terminal,so that my CLI work there?
- 06-04-2008 #2
If by "new terminal" you mean a new console window, use one of these two mechanisms to run xterm:
- system()
- fork(), followed by one of the functions in the exec family.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 06-04-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 2
but in that case it will be a different process...right..but for my case what ever running in the two consoles are same processes,that is CLI is only a thread of the main module...?
- 06-04-2008 #4A thousand apologies. I had failed to read this in your original question:what ever running in the two consoles are same processes,that is CLI is only a thread of the main module
The easiest way I can think of doing what you want to do is still kind of klugey.I am spawning a new thread for CLI and it is using the same address space of the above module.
- From either thread, fork() a new process. In that new process, you won't need to worry about the other thread running; it's automatically dead.
- In that new process, execsomething() xterm, using the appropriate xterm option to run a new program.
- In that new program, initiate two-way communication with your auxiliary thread in the main program. Use pipes, or named pipes (FIFO's), or network connections (overkill, in my opinion), or POSIX message queues (bad because the queues persist if the programs exit).
- Have your auxiliary thread send to that new program what it wants to write to the window, and receive from that program what the user types at the window.
Hokey, I know. But I can't think of an easier way to do this.--
Bill
Old age and treachery will overcome youth and skill.
- 06-05-2008 #5Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
I'd start by looking at uxrvt. It installs an urxvtd binary which can be loaded as a daemon. After that you can run urxvtc instead of the regular urxvt. Urxvtc is a client for urxvtd, which means that you can run as many clients as you want and still have only one daemon loaded in the background.
It's just one of the many lovely features of urxvtc that makes it really light on memory usage when you have to open a thousand terminal windows.
You can reuse that or use it as an example or as a inspiration :P


Reply With Quote