我知道这waitpid()用于等待一个过程完成,但是如何才能完全使用它?
在这里我想做的是,创造两个孩子并等待第一个孩子完成,然后在退出前杀死第二个孩子.
//Create two children
pid_t child1;
pid_t child2;
child1 = fork();
//wait for child1 to finish, then kill child2
waitpid() ... child1 {
kill(child2) }
Run Code Online (Sandbox Code Playgroud) 有没有办法实现这样的事情:
for row in rows:
try:
something
except:
restart iteration
Run Code Online (Sandbox Code Playgroud)