hi
In the "traptest" script below I want the script say "bye" and exit if it gets a SIGHUP signal.
In the "mycommand" script which is called from "traptest" I send the SIGHUP signal.
#!/bin/bash
#mycommand
calledprg=
while [ "$1" != "" ]; do
case $1 in
-s ) shift
calledprg=$1
;;
* ) exit 1
esac
shift
done
if [ "$calledprg" != "" ];then
pkill -s 1 $calledprg
fi
exit
#!/bin/bash
#traptest
PROGNAME=$(basename $0)
echo "$PROGNAME"
trap " echo "byeeeeeeeeeee" ; exit " SIGHUP
mycommand -s $PROGNAME
while :
do
echo "sleeeeppppp"
sleep 60
done
but I get
line 5: trap: have: invalid signal specification
line 5: trap: finished ; exit : invalid signal specification
what is wrong with these 2 scripts?
Also in some tutorials
they say SIGKILL should not be used if not urgent.Why?Instead of SIGKILL what would be used that makes sure that the program will be killed in any case?(in another script I used pkill -s 9 but I am not confident because of these comments
)
Thank u for reading all these
and thank u much more if u have any idea