bash trap: Cleaning Up After an Interrupted Script
A script killed mid-execution leaves a temp file or lockfile behind, unless trap catches the signal first. SIGKILL remains impossible to intercept.
A script killed mid-execution leaves a temp file or lockfile behind, unless trap catches the signal first. SIGKILL remains impossible to intercept.
Une commande lancée avec & tourne en arrière-plan mais meurt quand même à la fermeture du terminal : le shell envoie SIGHUP à ses enfants. nohup et disown évitent ça.
Un script tué en pleine exécution laisse un lockfile derrière lui, sauf si trap intercepte le signal avant. SIGKILL reste impossible à intercepter, quel que soit le trap défini.
Launching a command with & runs it in the background, but it still dies when the terminal closes: the shell sends SIGHUP to its children. nohup and disown prevent that.
set -e n'arrête jamais un script à l'intérieur d'un if ni d'une condition &&. Comprendre les trois options séparément évite le faux sentiment de sécurité.
What set -euo pipefail actually means, flag by flag: set -e never catches an error inside an if or an && condition, and each flag catches something else.