Click here to Skip to main content
15,940,921 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am running program B(B.exe) from program A(A.exe) using the function
system(path of B.exe);
But the problem is, when i run my A.exe file, it gets stuck on the line of
system(path of B.exe);
unless i terminate the B.exe file from inside B.exe. But i want to terminate the B.exe file from inside A.exe after a certain period of time. How can i do that?

What I have tried:

I am using system(path of B.exe);
Updated 24-Apr-16 21:10pm

1 solution

The problem is that the system call is waiting for the end of B. That is named "blocking call". To avoid it you must use a non-blocking or async call.

Because your operating system is missing I take two guesses:

On Windows you need the handle and end the process with TerminateThread.

On Linux you can use the kill command, if you have the pid of the process.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900