English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

closing a program

i already know that
system("program.exe")
opens that program

but how do i make it where it closes a program?

2007-02-13 04:31:47 · 3 answers · asked by patdog 3 in Computers & Internet Programming & Design

3 answers

Well system() is NOT suppose to return until its finished.

BUT if I had to write some UGLY code to close and kill this program.exe.:

#include
#include
#include
...
pid_t child;

child = fork();

//we now have 2 process running.

if (child == 0) {
//this is the child process
//start program.exe
system("programe.exe");
//program.exe finishes, just exit the program
exit();
}
if (child > 0) {
//this is the parent process
//if the child process running program.exe is taking too long
//then
result = killpg(child, SIGKILL);
}

I haven't tried this but I think something like this would work if you want to continue to use system();

2007-02-13 05:46:51 · answer #1 · answered by bytekhan 2 · 1 0

commonly, you should use a C++ compiler to collect C courses. C++ is an extension of C. imagine of it as a prevalent C compiler with added help that shall we it parse and collect merchandise-orientated resource statements. C++ resource code seems very comparable to Java. no matter in case your courses will collect or no longer relies upon on how old your version of quick C is. I actual have used quick C a million.5 for DOS in view that I first offered it in the early Nineties. In that version, an integer (int) is in trouble-free words 2 bytes. i have not in any respect used seen C++, yet i'm efficient it makes use of four-bytes because the default length for an int. The interfaces to C library workouts have replaced somewhat too over the years. i have had blended consequences compiling a number of my old quick C a million.5 courses using gcc on Linux. solid success!

2016-11-27 20:22:05 · answer #2 · answered by ? 4 · 0 0

if you don't get an answer here... check http://www.planetsourcecode.com

2007-02-13 05:01:19 · answer #3 · answered by Killing Hours 1 · 0 1

fedest.com, questions and answers