请解释一下:
#!/bin/bash
# This is scripta.sh
./scriptb.sh &
pid=$!
echo $pid started
sleep 3
while true
do
kill -SIGINT $pid
echo scripta.sh $$
sleep 3
done
Run Code Online (Sandbox Code Playgroud)
——
#!/bin/bash
# This is scriptb.sh
trap "echo Ouch;" SIGINT
while true
do
echo scriptb.sh $$
sleep 1
done
Run Code Online (Sandbox Code Playgroud)
当我运行./scripta.sh陷阱不打印。如果我从 SIGINT 切换到任何其他信号(我尝试了 SIGTERM、SIGUSR1),陷阱会按预期打印“哎哟”。这怎么会发生?