Ctrl-C Kills Nohup Background Processes
This page answers questions like these:
- Why is Ctrl-C killing my background processes?
- Why does Ctrl-C kill my background processes?
- Why is Ctrl-C killing my nohup processes?
- Why does Ctrl-C kill my nohup processes?
Why is Ctrl-C Killing My Background Processes?
On some systems, using Ctrl-C to kill the currently running process will also kill sub-processes, even if they've been started with nohup.
To remedy this, the subprocesses need to be started using setsid as follows:
setsid nohup COMMAND &
- setsid runs its first argument (nohup) with a new Process Group ID, thus stopping Ctrl-C from killing it.
- nohup runs its first argument (COMMAND) such that it will ignore hangup signals (SIGHUP).
- & runs setsid in the background.
- This command can be used on the command line or inside a shell script.
Make Faster on a Multicore or Multi CPU Machine
Home > Linux / Unix > Ctrl-C Kills Nohup Background Processes
Tags: ctrl c, kills background processes, kills, nohup, background, processes, linux, unix