xuhdev
xuhdev

Reputation: 9323

After a timeout, kill the process and all its subprocesses

I know there is a doalarm program which can kill the spawned process after a timeout. Is there a way to kill all its subprocesses as well?

Upvotes: 0

Views: 88

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136208

Make your application run in a new session using setsid <app> .... That is also going to make the process a group leader.

And 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.

Upvotes: 2

Related Questions