On 08/06/2014 06:17 PM, Carlos E. R. wrote:
The code I have now is:
echo "waiting..." ; sleep 5 echo "Going to sync time:" $LOGGER -t $TAG -p $FACILIDAD "Going to sync time now." /usr/sbin/rcntp ntptimeset $LOGGER -t $TAG -p $FACILIDAD "Time should be synced now." echo "Time should be synced now."
And the log I got a minute ago was this:
2014-08-06T18:08:21,470279636+0200 - Going up Got enp0s29f7u1, IPv4.0 (host and GW): '192.168.42.154/24 192.168.42.129', IPv4.1: '' Cambiando la IP en /etc/hosts a 192.168.42.154 - Samsung android usb tether. waiting... Going to sync time: 6 Aug 18:08:26 sntp[24268]: Started sntp Got and ignored signal SIGTERM in nm-mine-hook Time should be synced now.
I read it that the script survived the kill attempt, but sntp did not.
ooh, that's nasty. Well, you only have to tell rcntp to also ignore TERM. ;-) As it's a shell script, you could e.g. do something like (untested): sh -c "trap '' TERM && source /usr/sbin/rcntp ntptimeset" E.g. script "x.sh": #!/bin/sh trap 'echo trapped TERM' 15 echo start sleep 2 sh -c 'trap "trapped TERM" 15 && source ./x2.sh start' echo done and "x2.sh": #!/bin/sh echo start x2 sleep 10 echo done x2 And then killing x.sh after 4 seconds with TERM: ./x.sh & sleep 4 && kill -TERM $! [1] 7228 start start x2 done x2 trapped TERM done Here's a nice article about advanced issues with trap()ing signals while attempting to return the correct error code. https://lists.gnu.org/archive/html/coreutils/2014-04/msg00046.html Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org