| 331 | |
| 332 | |
| 333 | void AsyncCommandExecutor::stopped_cleanup() |
| 334 | { |
| 335 | DBG_FUNCTION_ENTER_MSG; |
| 336 | if (this->running_ || !this->stopped_cleanup_needed()) // huh? |
| 337 | return; |
| 338 | |
| 339 | // remove stop timeout callbacks |
| 340 | unset_stop_timeouts(); |
| 341 | |
| 342 | // various statuses (see waitpid (2)): |
| 343 | if (WIFEXITED(waitpid_status_)) { // exited normally |
| 344 | const int exit_status = WEXITSTATUS(waitpid_status_); |
| 345 | |
| 346 | if (exit_status != 0) { |
| 347 | // translate the exit_code into a message |
| 348 | const std::string msg = (translator_func_ ? translator_func_(exit_status) |
| 349 | : "[no translator function, exit code: " + std::to_string(exit_status)); |
| 350 | push_error(Error<int>("exit", ErrorLevel::Warn, exit_status, msg)); |
| 351 | } |
| 352 | |
| 353 | } else { |
| 354 | if (WIFSIGNALED(waitpid_status_)) { // exited by signal |
| 355 | const int sig_num = WTERMSIG(waitpid_status_); |
| 356 | |
| 357 | // If it's not our signal, treat as error. |
| 358 | // Note: they will never match under win32 |
| 359 | if (sig_num != this->kill_signal_sent_) { |
| 360 | push_error(Error<int>("signal", ErrorLevel::Error, sig_num)); |
| 361 | } else { // it's our signal, treat as warning |
| 362 | push_error(Error<int>("signal", ErrorLevel::Warn, sig_num)); |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | g_spawn_close_pid(this->pid_); // needed to avoid zombies |
| 368 | |
| 369 | cleanup_members(); |
| 370 | |
| 371 | this->running_ = false; |
| 372 | DBG_FUNCTION_EXIT_MSG; |
| 373 | } |
| 374 | |
| 375 | |
| 376 |
no test coverage detected