Improve error logging in ThreadExecutor
This commit is contained in:
parent
7202a51065
commit
5fefaf4166
|
@ -30,6 +30,7 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <cstring>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ThreadExecutor::ThreadExecutor(const std::vector<std::string> &filenames, const std::map<std::string, long> &filesizes, Settings &settings, ErrorLogger &errorLogger)
|
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) {
|
if (i < _filenames.size() && rpipes.size() < _settings._jobs) {
|
||||||
int pipes[2];
|
int pipes[2];
|
||||||
if (pipe(pipes) == -1) {
|
if (pipe(pipes) == -1) {
|
||||||
perror("pipe");
|
std::cerr << "pipe() failed: "<< strerror(errno) << std::endl;
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if ((flags = fcntl(pipes[0], F_GETFL, 0)) < 0) {
|
if ((flags = fcntl(pipes[0], F_GETFL, 0)) < 0) {
|
||||||
perror("fcntl");
|
std::cerr << "fcntl(F_GETFL) failed: "<< strerror(errno) << std::endl;
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fcntl(pipes[0], F_SETFL, flags | O_NONBLOCK) < 0) {
|
if (fcntl(pipes[0], F_SETFL, flags | O_NONBLOCK) < 0) {
|
||||||
perror("fcntl");
|
std::cerr << "fcntl(F_SETFL) failed: "<< strerror(errno) << std::endl;
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
// Error
|
// Error
|
||||||
std::cerr << "Failed to create child process" << std::endl;
|
std::cerr << "Failed to create child process: "<< strerror(errno) << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} else if (pid == 0) {
|
} else if (pid == 0) {
|
||||||
close(pipes[0]);
|
close(pipes[0]);
|
||||||
|
|
Loading…
Reference in New Issue