Improve error logging in ThreadExecutor
This commit is contained in:
parent
7202a51065
commit
5fefaf4166
|
@ -30,6 +30,7 @@
|
|||
#include <cstdio>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
ThreadExecutor::ThreadExecutor(const std::vector<std::string> &filenames, const std::map<std::string, long> &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]);
|
||||
|
|
Loading…
Reference in New Issue