Find the answer to your Linux question:
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 ...
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    2

    Question 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?

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    If by "new terminal" you mean a new console window, use one of these two mechanisms to run xterm:
    1. system()
    2. fork(), followed by one of the functions in the exec family.

    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Just 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...?

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    what ever running in the two consoles are same processes,that is CLI is only a thread of the main module
    A thousand apologies. I had failed to read this in your original question:
    I am spawning a new thread for CLI and it is using the same address space of the above module.
    The easiest way I can think of doing what you want to do is still kind of klugey.
    1. 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.
    2. In that new process, execsomething() xterm, using the appropriate xterm option to run a new program.
    3. 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).
    4. 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.

  5. #5
    Linux 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...