How to kill a child process by the parent process?
问题 I create a child process using a fork() . How can the parent process kill the child process if the child process cannot complete its execution within 30 seconds? I want to allow the child process to execute up to 30 seconds. If it takes more than 30 seconds, the parent process will kill it. Do you have any idea to do that? 回答1: Send a SIGTERM or a SIGKILL to it: http://en.wikipedia.org/wiki/SIGKILL http://en.wikipedia.org/wiki/SIGTERM SIGTERM is polite and lets the process clean up before it