From 04e95cfcf325554191661405ee4069911896b127 Mon Sep 17 00:00:00 2001 From: Ian Roddis Date: Mon, 10 Jan 2022 13:12:19 -0400 Subject: [PATCH] Making fork process more descriptive in the case of failure --- libdaggy/src/executors/task/ForkingTaskExecutor.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libdaggy/src/executors/task/ForkingTaskExecutor.cpp b/libdaggy/src/executors/task/ForkingTaskExecutor.cpp index f645c13..0182b13 100644 --- a/libdaggy/src/executors/task/ForkingTaskExecutor.cpp +++ b/libdaggy/src/executors/task/ForkingTaskExecutor.cpp @@ -108,7 +108,7 @@ std::future ForkingTaskExecutor::execute( daggy::AttemptRecord ForkingTaskExecutor::runTask(const Task &task, std::atomic &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)) {