超时后,杀死进程及其所有子进程

After a timeout, kill the process and all its subprocesses

我知道有一个 doalarm 程序可以在超时后终止生成的进程。有没有办法也杀死它的所有子进程?

使用 setsid <app> ... 在新会话中创建您的应用程序 运行。这也将使流程成为组长。

when the group leader terminates

If the process is a controlling process, the SIGHUP signal shall be sent to each process in the foreground process group of the controlling terminal belonging to the calling process.