From 5fefaf4166d57bc2c9fa2066f1ac8f78c7a41dce Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Wed, 9 Nov 2011 22:15:53 +0200 Subject: [PATCH] Improve error logging in ThreadExecutor --- cli/threadexecutor.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 9b980018f..25b80e655 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #endif ThreadExecutor::ThreadExecutor(const std::vector &filenames, const std::map &filesizes, Settings &settings, ErrorLogger &errorLogger) @@ -137,25 +138,25 @@ unsigned int ThreadExecutor::check() if (i < _filenames.size() && rpipes.size() < _settings._jobs) { int pipes[2]; if (pipe(pipes) == -1) { - perror("pipe"); - exit(1); + std::cerr << "pipe() failed: "<< strerror(errno) << std::endl; + exit(EXIT_FAILURE); } int flags = 0; if ((flags = fcntl(pipes[0], F_GETFL, 0)) < 0) { - perror("fcntl"); - exit(1); + std::cerr << "fcntl(F_GETFL) failed: "<< strerror(errno) << std::endl; + exit(EXIT_FAILURE); } if (fcntl(pipes[0], F_SETFL, flags | O_NONBLOCK) < 0) { - perror("fcntl"); - exit(1); + std::cerr << "fcntl(F_SETFL) failed: "<< strerror(errno) << std::endl; + exit(EXIT_FAILURE); } pid_t pid = fork(); if (pid < 0) { // Error - std::cerr << "Failed to create child process" << std::endl; + std::cerr << "Failed to create child process: "<< strerror(errno) << std::endl; exit(EXIT_FAILURE); } else if (pid == 0) { close(pipes[0]);