Skip to content

[swss.sh/syncd.sh] Trap only on EXIT#78

Closed
stepanblyschak wants to merge 1 commit intomasterfrom
trap-exit-fix
Closed

[swss.sh/syncd.sh] Trap only on EXIT#78
stepanblyschak wants to merge 1 commit intomasterfrom
trap-exit-fix

Conversation

@stepanblyschak
Copy link
Copy Markdown
Owner

@stepanblyschak stepanblyschak commented Jul 28, 2022

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:

#!/bin/bash
trap "echo Handled SIGTERM" 0 2 3 15

echo "Before sleep"
sleep inf
echo "After sleep"

On SIGTERM sent to the followig script:

+ trap 'echo Handled SIGTERM' 15
+ echo Before sleep
Before sleep
+ sleep inf

Terminated
++ echo Handled SIGTERM
Handled SIGTERM
+ echo After sleep
After sleep

"echo After sleep" shouldn't be printed, the script has to exit.

Instead, trap only on EXIT which covers also a scenario with exit on
SIGINT, SIGTERM.

Signed-off-by: Stepan Blyschak [email protected]

Why I did it

When NVIDIA switch is first booting FW upgrade process starts, if user does ztp disable -y during that process, which calls config reload -y -f all services will be terminated, including syncd and running FW upgrade process, however, it is observed that syncd.sh does not terminate but continues loading kernel drivers. This will cause an issue on next syncd start leading to switch init failure.

How I did it

Changed the signal for trap.

How to verify it

Boot NVIDIA switch first time, do "ztp disable -y", verify after some time all services are started and running.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

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]>
stepanblyschak pushed a commit that referenced this pull request Dec 19, 2023
…utomatically (sonic-net#16842)

#### Why I did it
src/sonic-host-services
```
* fc88254 - (HEAD -> 202305, origin/202305) Support to config fips state (#69) (#78) (16 hours ago) [xumia]
```
#### How I did it
#### How to verify it
#### Description for the changelog
stepanblyschak pushed a commit that referenced this pull request May 20, 2025
…est HEAD automatically (sonic-net#1039)

#### Why I did it
src/sonic-platform-common
```
* 60b9fcf - (HEAD -> 202412, origin/202412) Fix alignment for _create_cmis_api() (#78) (4 hours ago) [Prince George]
```
#### How I did it
#### How to verify it
#### Description for the changelog
stepanblyschak pushed a commit that referenced this pull request May 20, 2025
…tomatically (sonic-net#1123)

#### Why I did it
src/sonic-swss
```
* 2a0856b - (HEAD -> 202412, origin/202412) Merge pull request #78 from nazariig/202412-trim-azure (7 hours ago) [Nazarii Hnydyn]
```
#### How I did it
#### How to verify it
#### Description for the changelog
stepanblyschak pushed a commit that referenced this pull request Dec 3, 2025
…ly (sonic-net#24654)

#### Why I did it
src/sonic-stp
```
* 6be3721 - (HEAD -> master, origin/master, origin/HEAD) Correcting stp-stpmgrd IPC data structure similar to structure defined in stpmgr.h file (#80) (4 days ago) [Divya Kumaran Chandralekha]
* e80c7be - [stpctl] stpctl enhancements for mstp debugging commands (#79) (5 days ago) [vganesan-nokia]
* bfcb492 - [mstp] Fix for port enable handlinging and rx pkt type check (#78) (5 days ago) [vganesan-nokia]
```
#### How I did it
#### How to verify it
#### Description for the changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants