void ForkExecParent::checkCompletion() throw () { if (m_hasQuit && !m_out && !m_err) { try { m_onQuit(m_status); if (!m_hasConnected || m_status != 0) { SE_LOG_DEBUG(NULL, NULL, "ForkExecParent: child was signaled %s, signal %d, int %d, term %d, int sent %s, term sent %s", WIFSIGNALED(m_status) ? "yes" : "no", WTERMSIG(m_status), SIGINT, SIGTERM, m_sigIntSent ? "yes" : "no", m_sigTermSent ? "yes" : "no"); if (WIFSIGNALED(m_status) && ((WTERMSIG(m_status) == SIGINT && m_sigIntSent) || (WTERMSIG(m_status) == SIGTERM && m_sigTermSent))) { // not an error when the child dies because we killed it return; } std::string error = "child process quit"; if (!m_hasConnected) { error += " unexpectedly"; } if (WIFEXITED(m_status)) { error += StringPrintf(" with return code %d", WEXITSTATUS(m_status)); } else if (WIFSIGNALED(m_status)) { error += StringPrintf(" because of signal %d\n", WTERMSIG(m_status)); } else { error += " for unknown reasons"; } SE_LOG_ERROR(NULL, NULL, "%s", error.c_str()); m_onFailure(STATUS_FATAL, error); } } catch (...) { std::string explanation; SyncMLStatus status = Exception::handle(explanation); try { m_onFailure(status, explanation); } catch (...) { Exception::handle(); } } } }
void PipelineInterests::fail(const std::string& reason) { std::cerr << "Interest Pipeline failed because: " << reason << std::endl; m_hasError = true; m_hasFailure = true; if (m_onFailure) m_face.getIoService().post([this, reason] { m_onFailure(reason); }); cancel(); }
void ForkExecParent::newClientConnection(GDBusCXX::DBusConnectionPtr &conn) throw() { try { SE_LOG_DEBUG(NULL, NULL, "ForkExecParent: child %s has connected", m_helper.c_str()); m_hasConnected = true; #ifndef GDBUS_CXX_HAVE_DISCONNECT m_api.reset(new ForkExecParentDBusAPI(conn)); #endif m_onConnect(conn); } catch (...) { std::string explanation; SyncMLStatus status = Exception::handle(explanation); try { m_onFailure(status, explanation); } catch (...) { Exception::handle(); } } }