#!/bin/sh
trap 'trap - EXIT; echo exit' EXIT
trap 'echo term; exit' TERM
sleep 100
If I run kill
for the PID of the shell process of the script, it does not terminate.
If I remove the TERM trap, and do the same, the shell will terminate. Why? Similarly, if I replace sleep 100
by sleep 100 & wait
, the shell will terminate by kill
.