Making fork process more descriptive in the case of failure
This commit is contained in:
@@ -108,7 +108,7 @@ std::future<daggy::AttemptRecord> ForkingTaskExecutor::execute(
|
||||
daggy::AttemptRecord ForkingTaskExecutor::runTask(const Task &task,
|
||||
std::atomic<bool> &running)
|
||||
{
|
||||
AttemptRecord rec;
|
||||
AttemptRecord rec{.rc = -1};
|
||||
|
||||
rec.startTime = Clock::now();
|
||||
|
||||
@@ -148,19 +148,20 @@ daggy::AttemptRecord ForkingTaskExecutor::runTask(const Task &task,
|
||||
int stdoutPipe[2];
|
||||
int pipeRC = pipe2(stdoutPipe, O_DIRECT);
|
||||
if (pipeRC != 0) {
|
||||
std::cerr << "Unable to create pipe for stdout: " << pipeRC << std::endl;
|
||||
throw std::runtime_error("Unable to create pipe for stdout");
|
||||
rec.executorLog = "Unable to create pipe for stdout, check limits";
|
||||
return rec;
|
||||
}
|
||||
int stderrPipe[2];
|
||||
pipeRC = pipe2(stderrPipe, O_DIRECT);
|
||||
if (pipeRC != 0) {
|
||||
std::cerr << "Unable to create pipe for stderr" << std::endl;
|
||||
throw std::runtime_error("Unable to create pipe for stderr");
|
||||
rec.executorLog = "Unable to create pipe for stderr, check limits";
|
||||
return rec;
|
||||
}
|
||||
|
||||
pid_t child = fork();
|
||||
if (child < 0) {
|
||||
throw std::runtime_error("Unable to fork child");
|
||||
rec.executorLog = "Unable to fork.";
|
||||
return rec;
|
||||
}
|
||||
else if (child == 0) { // child
|
||||
while ((dup2(stdoutPipe[1], STDOUT_FILENO) == -1) && (errno == EINTR)) {
|
||||
|
||||
Reference in New Issue
Block a user