| 257 | |
| 258 | |
| 259 | bool 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 |
no test coverage detected