How to close a dd process that was started in a dash script with -SIGINT?


When I start a dd process directly from the Terminal with

dd if=/dev/zero of=/dev/null &

command, and send to it a -SIGINT with

kill -SIGINT <pid>

command, it closes successfully.

But when I start the process from a script

dd if=/dev/zero of=/dev/null &

Then do

kill -SIGINT <pid>

it doesn’t affect the process.

I wonder why this is so.
I didn’t find any related information on the internet.


POSIX says:

If job control is disabled (see the description of set -m) when the shell executes an asynchronous list, the commands in the list shall inherit from the shell a signal action of ignored (SIG_IGN) for the SIGINT and SIGQUIT signals.

This is likely because Ctrl+C sends a sigint to every process in the group, so without this behavior, any backgrounded processes would unexpectedly be killed when you try to interrupt the main script.

Answered By – that other guy

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published