MCPcopy Create free account
hub / github.com/ashaduri/gsmartcontrol / try_stop

Method try_stop

src/applib/async_command_executor.cpp:259–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257
258
259bool AsyncCommandExecutor::try_stop(hz::Signal sig)
260{
261 DBG_FUNCTION_ENTER_MSG;
262 if (!this->running_ || this->pid_ == 0)
263 return false;
264
265 // other variants: SIGHUP(1) (terminal closed), SIGINT(2) (Ctrl-C),
266 // SIGKILL(9) (kill).
267 // Note that SIGKILL cannot be trapped by any process.
268
269 if (process_signal_send(this->pid_, sig) == 0) { // success
270 this->kill_signal_sent_ = static_cast<int>(sig); // just the number to compare later.
271 return true; // the rest is done by a handler
272 }
273
274 // Possible: EPERM (no permissions), ESRCH (no such process, or zombie)
275 push_error(Error<int>("errno", ErrorLevel::Error, errno));
276
277 DBG_FUNCTION_EXIT_MSG;
278 return false;
279}
280
281
282

Callers 2

cmdex_on_term_timeoutFunction · 0.45
cmdex_on_kill_timeoutFunction · 0.45

Calls 1

process_signal_sendFunction · 0.85

Tested by

no test coverage detected