rhinoinrepose
rhinoinrepose

Reputation: 2151

Please explain: trap 'sudo kill -9 -- -$$' EXIT

What is this shell command doing?

 trap 'sudo kill -9 -- -$$' EXIT

Upvotes: 9

Views: 826

Answers (1)

Zombo
Zombo

Reputation: 1

  • $$ is the process ID of the script itself
  • -$$ means use the process group ID
  • -- signals the end of options

So upon exit the trap will kill all subprocesses of the script.

§ Internal Variables

Upvotes: 6

Related Questions