pseudo code in my xxx.sh
a large loop {
python xxx.py
}
when I run this script ./xxx.sh
and some bugs in python, then exception info will be raised to stdout repeatedly.
if I press ctrl+c, the signal will be catched by python, and if I press ctrl+z, the xxx.sh
will be sleep in the background.
So, I am trying to add some trap code to catch ctrl+z,
the trap code in my xxx.sh
function stop_ctrl_z() {
echo $$
pkill -9 $$
}
trap stop_ctrl_z SIGTSTP
But xxx.sh
cannot stop itself when met ctrl+z as my expected.
It hangs up, sadly I must open another terminal and use pkill -9 xxx.sh
to stop this script.
^Z^Z^Z^Z^Z^Z^Z^Z^Z^Z
Does someone has solution to solve my problem?