How to properly catch SIGQUIT in a bash script?

I can write shell scripts that catch SIGINTjust fine, but I can't catch SIGQUIT.

#!/bin/bash

function die {
    echo "Dying on signal $1"
    exit 0
}

trap 'die "SIGINT"' SIGINT
trap 'die "SIGQUIT"' SIGQUIT

while true; do
    echo "sleeping..."
    sleep 5
done

Running this script and pressing CTRL-Chas the desired effect, but pressing CTRL-\(which, as I understand it, should run SIGQUIT) does nothing except print ^\in the terminal. Why?

I have two running theories. Firstly, semantics SIGINT, and SIGQUITis different in that SIGQUITonly sent to the child process sleep, and SIGINTsent to the child process and the parent process of bash, if so, where it documented?

, bash (.. no-op ) SIGQUIT ( ), . , , SIGQUIT , , (bash) . , SIGQUIT bash script?... , shopt ?

: Ubuntu 10.10 gnome-terminal 2.32.0 bash 4.1.5 yes ^\ SIGQUIT ( stty -a) ^\ SIGQUITs , ping).

UPDATE: , - -. script (.. ctrl-alt-f1, X), SIGQUIT, ^\. bash , . , : gnome-terminal, ? diff 'd stty -a gnome-, , (, quit = ^\;).

2: . $ sleep 60 gnome-terminal; ^\, . $ sleep 60 ; ^\ - Quit . $ ping google.com gnome-terminal ^\ - , . , - gnome-, SIGQUIT , , do . , -.

+3
2

, - gnome-terminal 2.32.0; Ubuntu 11.04, gnome-terminal 2.32.1 ( bash 4.2.8), SIGQUIT , .

+2

Fedora 19 XFCE: ps s, bash xfce4- SIGQUIT, yes >/dev/null &, ps s , SIGQUIT. ( ) ssh localhost, ssh SIGQUIT, yes >/dev/null & .

, gnome-terminal, , : vte. vte-0.28.2-9.fc19.x86_64.

0

All Articles