I run an external program with C++:
_wsystem(exec);
I want to kill the process if it runs for more than n seconds. I can do it in Python like this:
p = subprocess.Popen(self.temp_exec, shell=True)
cur_time = 0.0
while cur_time < self.time_limit:
if p.poll() != None:
# Kill the process
p.terminate()
break
time.sleep(0.1)
cur_time += 0.1
What's the alternative of p.poll() and p.terminate() in C++?
Thank you
P.S. Solutions involving WinAPI are welcome too.