shell 信号

#!/bin/sh
trap "echo SIGINT;exit 0;" SIGINT

trap "echo SIGKILL;exit 0;"  SIGKILL

trap "echo SIGTERM;exit 0;"  SIGTERM

while true
do
sleep 10
done
 

 

kill -SIGINT `ps aux|grep trap |grep -v grep |awk '{print $2}'`

 

kill -SIGTERM `ps aux|grep trap |grep -v grep |awk '{print $2}'`

 

kill -SIGKILL   `ps aux|grep trap |grep -v grep |awk '{print $2}'`

 

 

你可能感兴趣的:(shell,信号)