运行.exe并继续

问题描述:

我正在使用函数

system(path of B.exe);

但是问题是,当我运行我的A.exe文件时,它会卡在

But the problem is, when i run my A.exe file, it gets stuck on the line of

system(path of B.exe);

除非我终止B.exe来自B.exe内部的文件。但我想在一段时间后从A.exe内部终止B.exe文件。我怎么能这样做?



我的尝试:



我正在使用系统(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);

问题是系统调用正在等待B的结束。这被命名为阻塞调用 。为了避免这种情况,你必须使用非阻塞或异步调用。



因为你的操作系统缺失我需要两个猜测:



在Windows上你需要句柄并用TerminateThread结束进程。



在Linux上你可以使用kill 命令,如果你有进程的pid。
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.