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.