@@ -132,23 +132,44 @@ void TeamMgr::cleanTeamProcesses()
132
132
std::string res;
133
133
pid_t pid;
134
134
135
+ try
135
136
{
136
137
std::stringstream cmd;
137
138
cmd << " cat " << shellquote (" /var/run/teamd/" + alias + " .pid" );
138
139
EXEC_WITH_ERROR_THROW (cmd.str (), res);
140
+ }
141
+ catch (const std::exception &e)
142
+ {
143
+ // Handle Warm/Fast reboot scenario
144
+ SWSS_LOG_NOTICE (" Skipping non-existent port channel %s pid..." , alias.c_str ());
145
+ continue ;
146
+ }
139
147
148
+ try
149
+ {
140
150
pid = static_cast <pid_t >(std::stoul (res, nullptr , 10 ));
141
151
aliasPidMap[alias] = pid;
142
152
143
153
SWSS_LOG_INFO (" Read port channel %s pid %d" , alias.c_str (), pid);
144
154
}
155
+ catch (const std::exception &e)
156
+ {
157
+ SWSS_LOG_ERROR (" Failed to read port channel %s pid: %s" , alias.c_str (), e.what ());
158
+ continue ;
159
+ }
145
160
161
+ try
146
162
{
147
163
std::stringstream cmd;
148
164
cmd << " kill -TERM " << pid;
149
165
EXEC_WITH_ERROR_THROW (cmd.str (), res);
150
166
151
- SWSS_LOG_INFO (" Sent SIGTERM to port channel %s pid %d" , alias.c_str (), pid);
167
+ SWSS_LOG_NOTICE (" Sent SIGTERM to port channel %s pid %d" , alias.c_str (), pid);
168
+ }
169
+ catch (const std::exception &e)
170
+ {
171
+ SWSS_LOG_ERROR (" Failed to send SIGTERM to port channel %s pid %d: %s" , alias.c_str (), pid, e.what ());
172
+ aliasPidMap.erase (alias);
152
173
}
153
174
}
154
175
0 commit comments