@@ -487,8 +487,9 @@ static int execAppInternal(const char *appPath, const char *const *args, std::st
487
487
#elif defined(PLATFORM_UNIX)
488
488
// create pipes
489
489
int coutPipes[2 ], cerrPipes[2 ];
490
- pipe (coutPipes);
491
- pipe (cerrPipes);
490
+ if (pipe (coutPipes) != 0 || pipe (cerrPipes) != 0 ) {
491
+ throw std::runtime_error (argsToString (" Unable to create pipe: " , std::strerror (errno)));
492
+ }
492
493
const auto readCoutPipe = coutPipes[0 ], writeCoutPipe = coutPipes[1 ];
493
494
const auto readCerrPipe = cerrPipes[0 ], writeCerrPipe = cerrPipes[1 ];
494
495
@@ -500,7 +501,7 @@ static int execAppInternal(const char *appPath, const char *const *args, std::st
500
501
501
502
try {
502
503
if (child == -1 ) {
503
- throw runtime_error (" Unable to create fork" );
504
+ throw std:: runtime_error (argsToString ( " Unable to create fork: " , std::strerror (errno)) );
504
505
}
505
506
506
507
// init file descriptor set for poll
@@ -518,10 +519,10 @@ static int execAppInternal(const char *appPath, const char *const *args, std::st
518
519
do {
519
520
const auto retpoll = poll (fileDescriptorSet, 2 , timeout);
520
521
if (retpoll == 0 ) {
521
- throw runtime_error (" Poll time- out" );
522
+ throw std:: runtime_error (" Poll timed out" );
522
523
}
523
524
if (retpoll < 0 ) {
524
- throw runtime_error (" Poll failed" );
525
+ throw std:: runtime_error (argsToString ( " Poll failed: " , std::strerror (errno)) );
525
526
}
526
527
if (fileDescriptorSet[0 ].revents & POLLIN) {
527
528
const auto count = read (readCoutPipe, buffer, sizeof (buffer));
@@ -557,8 +558,10 @@ static int execAppInternal(const char *appPath, const char *const *args, std::st
557
558
} else {
558
559
// child process
559
560
// -> set pipes to be used for stdout/stderr
560
- dup2 (writeCoutPipe, STDOUT_FILENO);
561
- dup2 (writeCerrPipe, STDERR_FILENO);
561
+ if (dup2 (writeCoutPipe, STDOUT_FILENO) == -1 || dup2 (writeCerrPipe, STDERR_FILENO) == -1 ) {
562
+ std::cerr << Phrases::Error << " Unable to duplicate file descriptor: " << std::strerror (errno) << Phrases::EndFlush;
563
+ std::exit (EXIT_FAILURE);
564
+ }
562
565
close (readCoutPipe);
563
566
close (writeCoutPipe);
564
567
close (readCerrPipe);
0 commit comments