Thread: Opening an application through another application in C++ for Linux

  1. #1
    Registered User
    Join Date
    Dec 2014
    Posts
    3

    Opening an application through another application in C++ for Linux

    Hi,

    I want to open an application A from another application B. By opening it, I don't want to open it within B. I found many ways to call an application from within another. However, what I want to do is open the other one(A) simultaeneously. How can I achieve this? fork() and exec() seem to open A within B. I am developing a code for Linux and Mac. Advice would be appreciated.Thanks.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    What do you mean "within B?" fork() creates a new process that is a clone of the current one, and exec() then replaces that process with the new program that you specify.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Dec 2014
    Posts
    3
    No No, fork + exec() are opening the application within the service's terminal window. I want both of them to run concurrently without interrupting each other. The application should open in a new terminal window.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    fork() and exec() know nothing about "terminal windows." They are system calls, and have no knowledge of your windowing environment, or even the terminal. You can allocate a new virtual terminal, but I don't know how you would attach it to a new "terminal window."
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,398
    Quote Originally Posted by Elkvis View Post
    fork() and exec() know nothing about "terminal windows." They are system calls, and have no knowledge of your windowing environment, or even the terminal. You can allocate a new virtual terminal, but I don't know how you would attach it to a new "terminal window."
    Instead of executing the program directly, use xterm to execute it and it will pop a new window:

    Code:
    xterm -e <program> <args...>
    Call that with exec() instead of calling the program directly.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Call that with exec() instead of calling the program directly.
    O_o

    But inspect the environment ($TERM) first so that you have a change of using the preferred emulator.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-18-2012, 04:20 AM
  2. Opening a file with my application...
    By manugarciac in forum Windows Programming
    Replies: 2
    Last Post: 05-06-2007, 11:28 PM
  3. Using a Web Browser within your Linux Application
    By CaptainRon in forum Linux Programming
    Replies: 7
    Last Post: 12-21-2006, 08:22 AM
  4. opening an external application
    By scotland in forum C++ Programming
    Replies: 3
    Last Post: 07-06-2003, 09:20 AM
  5. opening html files in application
    By Ripper1 in forum Windows Programming
    Replies: 8
    Last Post: 04-27-2003, 05:06 AM

Tags for this Thread