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

bash, command, shell, unix

Solution

- `$$` 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

Problem

What is this shell command doing? ``` trap 'sudo kill -9 -- -$$' EXIT ```

Original source