bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

prevent ignore SIGINT for asynchronous commands without enabling job con


From: Ilya Basin
Subject: prevent ignore SIGINT for asynchronous commands without enabling job control
Date: Wed, 10 Apr 2013 14:43:12 +0400

Hi.
I have a script that creates some background tasks.
I want the whole tree to be killed by Ctrl-C.

There's a requirement that the script process and its children must
belong to the same process group. This is why I can't enable job
control.

I don't want to use 'trap', because it adds complexity.

Example:

    #!/bin/bash
    sleep 90 &
    wait $!

After Ctrl-C "sleep 90" stays.

Using trap:

    #!/bin/bash
    
    trap 'trap - INT; kill -TERM $noeof_pid; kill -INT $$' INT

    sleep 90 &
    wait $!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]