Forked subprocess not exited if execve failed (#54)

* Fixed: forked subprocess not exited if execve failed

In lengthy processes (daemons, etc) this bug keeps open this subprocess. The subprocess continues to work (parallel to parent process) from after failed command start

* Fixed: deadlock on using multithreaded application

For example if application uses spdlog logger library and set spdlog::flush_every(std::chrono::seconds(1)); then it starts it's own thread which flushes logs every 1 second. In this case if execve failed to execute given command, then parent and subprocess deadlocked.
This commit is contained in:
Dilshod Mukhtarov 2020-04-14 18:59:25 +04:00 committed by GitHub
parent a458bcfc4a
commit f1a698b50e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1668,12 +1668,11 @@ namespace detail {
std::string err_msg(exp.what()); std::string err_msg(exp.what());
//ATTN: Can we do something on error here ? //ATTN: Can we do something on error here ?
util::write_n(err_wr_pipe_, err_msg.c_str(), err_msg.length()); util::write_n(err_wr_pipe_, err_msg.c_str(), err_msg.length());
throw;
} }
// Calling application would not get this // Calling application would not get this
// exit failure // exit failure
exit (EXIT_FAILURE); _exit (EXIT_FAILURE);
#endif #endif
} }