linux - Bash script entrypoint (PID=1) kills `tail` sub process ONLY if a fake trap (which does NOTHING) was there -
i facing strange behavior in bash
script, have bash
script running pid 1
(it entrypoint
docker
container, if not familier docker, assume can ignore info).
when run following script, sigterm
terminates quickly, , seems fine (please keep in mind sshd
service not exist! whole system starts script runs tail
nothing more, till not problem).
#!/bin/bash trap "pkill sshd" sigterm export path=/usr/local/samba/bin/:/usr/local/samba/sbin/:$path if [ -f /usr/local/samba/etc/smb.conf ]; exec /usr/local/samba/sbin/samba -i else tail -f /dev/null & wait ${!} fi
the problem comes when delete trap
. system hangs, , seems because tail till running , not end reason. (if familier docker, docker waits 10 seconds, , kill container, because didn't respond sigterm
, again if not familier docker, ignore info).
#!/bin/bash export path=/usr/local/samba/bin/:/usr/local/samba/sbin/:$path if [ -f /usr/local/samba/etc/smb.conf ]; exec /usr/local/samba/sbin/samba -i else tail -f /dev/null & wait ${!} fi
could 1 explain me problem exactly? why fake trap
makes work (although practically nothing, works because there).
i still want mention using empty trap
: trap "" sigterm
doesn't help, should there in trap work (even if nothing).
hope can me, thanks!
Comments
Post a Comment