Skip to content

Commit 7cb6db5

Browse files
committed
threadexecutor.cpp: return error exitcode when a pipe error occurred
1 parent 1bd1e8f commit 7cb6db5

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

cli/threadexecutor.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
9797

9898
if (type != REPORT_OUT && type != REPORT_ERROR && type != REPORT_INFO && type != CHILD_END) {
9999
std::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl;
100-
std::exit(0);
100+
std::exit(EXIT_FAILURE);
101101
}
102102

103103
unsigned int len = 0;
104104
if (read(rpipe, &len, sizeof(len)) <= 0) {
105105
std::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl;
106-
std::exit(0);
106+
std::exit(EXIT_FAILURE);
107107
}
108108

109109
// Don't rely on incoming data being null-terminated.
@@ -112,7 +112,7 @@ int ThreadExecutor::handleRead(int rpipe, unsigned int &result)
112112
const ssize_t readIntoBuf = read(rpipe, buf, len);
113113
if (readIntoBuf <= 0) {
114114
std::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl;
115-
std::exit(0);
115+
std::exit(EXIT_FAILURE);
116116
}
117117
buf[readIntoBuf] = 0;
118118

@@ -232,7 +232,7 @@ unsigned int ThreadExecutor::check()
232232
std::ostringstream oss;
233233
oss << resultOfCheck;
234234
writeToPipe(CHILD_END, oss.str());
235-
std::exit(0);
235+
std::exit(EXIT_SUCCESS);
236236
}
237237

238238
close(pipes[1]);
@@ -300,10 +300,10 @@ unsigned int ThreadExecutor::check()
300300
}
301301

302302
if (WIFEXITED(stat)) {
303-
const int exitstaus = WEXITSTATUS(stat);
304-
if (exitstaus != 0) {
303+
const int exitstatus = WEXITSTATUS(stat);
304+
if (exitstatus != EXIT_SUCCESS) {
305305
std::ostringstream oss;
306-
oss << "Child process exited with " << exitstaus;
306+
oss << "Child process exited with " << exitstatus;
307307
reportInternalChildErr(childname, oss.str());
308308
}
309309
} else if (WIFSIGNALED(stat)) {
@@ -334,7 +334,7 @@ void ThreadExecutor::writeToPipe(PipeSignal type, const std::string &data)
334334
delete [] out;
335335
out = nullptr;
336336
std::cerr << "#### ThreadExecutor::writeToPipe, Failed to write to pipe" << std::endl;
337-
std::exit(0);
337+
std::exit(EXIT_FAILURE);
338338
}
339339

340340
delete [] out;

0 commit comments

Comments
 (0)