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]);