Skip to content

Commit 211f536

Browse files
stepanblyschakskbarista
authored andcommitted
[swss.sh/syncd.sh] Trap only on EXIT (sonic-net#11590)
When using trap on SIGTERM the script will not react to the SIGTERM signal sent while a child is executing. I.e, the following script does not react on SIGTERM sent to it if it is waiting for sleep to finish: ``` trap "echo Handled SIGTERM" 0 2 3 15 echo "Before sleep" sleep inf echo "After sleep" ``` Instead, trap only on EXIT which covers also a scenario with exit on SIGINT, SIGTERM. Signed-off-by: Stepan Blyschak <[email protected]>
1 parent de473f2 commit 211f536

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

files/scripts/swss.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function lock_service_state_change()
3838

3939
exec {LOCKFD}>${LOCKFILE}
4040
/usr/bin/flock -x ${LOCKFD}
41-
trap "/usr/bin/flock -u ${LOCKFD}" 0 2 3 15
41+
trap "/usr/bin/flock -u ${LOCKFD}" EXIT
4242

4343
debug "Locked ${LOCKFILE} (${LOCKFD}) from ${SERVICE}$DEV service"
4444
}

files/scripts/syncd_common.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#
44
# common functions used by "syncd" scipts (syncd.sh, gbsyncd.sh, etc..)
55
# scripts using this must provide implementations of the following functions:
6-
#
6+
#
77
# startplatform
88
# waitplatform
99
# stopplatform1 and stopplatform2
10-
#
10+
#
1111
# For examples of these, see gbsyncd.sh and syncd.sh.
1212
#
1313

@@ -25,7 +25,7 @@ function lock_service_state_change()
2525

2626
exec {LOCKFD}>${LOCKFILE}
2727
/usr/bin/flock -x ${LOCKFD}
28-
trap "/usr/bin/flock -u ${LOCKFD}" 0 2 3 15
28+
trap "/usr/bin/flock -u ${LOCKFD}" EXIT
2929

3030
debug "Locked ${LOCKFILE} (${LOCKFD}) from ${SERVICE}$DEV service"
3131
}

0 commit comments

Comments
 (0)