LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to a start another application from my c++ program? (https://www.linuxquestions.org/questions/programming-9/how-to-a-start-another-application-from-my-c-program-209332/)

gajaykrishnan 07-24-2004 11:42 PM

how to a start another application from my c++ program?
 
how do i start another application from my c++ program ?????

gizmo_thunder 07-24-2004 11:57 PM

Is it on Windows or linux..???
in linux there is a system call "execvp" which can be used to
start another program replacing the current one.. if you want to
start another process you might want to use fork and then execvp
in windows there is WinExec( ) im' not sure about how to use it though :)

gajaykrishnan 07-25-2004 12:17 AM

it is a linux system and can take for eg. as
starting a web-browser for my c++ program without quitting it.

gizmo_thunder 07-25-2004 12:43 AM

check out the manual for execvp
man execvp :)
im' sure youll' be able to get the idea

Hko 07-25-2004 07:55 AM

1) If you just want to execute a program, wait for it to finish, then continue your program:
Use system()

2) If you want to start a program that runs on its own while your program also continues to run:
Use fork() in combination with execvp()

3) If you want to run a program and read from its stdout into your program (or write to its stdin from your program) through a pipe:
Use popen()

See these man pages for more information:
man 3 system
man 2 fork
man 3 execvp
man 3 popen

If necessary, google for examples. One site that deals with this among other things, is the freely downloadable book (as PDF's + seperate sample code) "Advanced Linux Programming" (New Riders). Check http://www.advancedlinuxprogramming.com/


All times are GMT -5. The time now is 04:08 AM.