Skip to content
Snippets Groups Projects
Commit 7c76f6c8 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

fix ignoring return value warn

parent dbd39826
No related branches found
No related tags found
No related merge requests found
......@@ -123,7 +123,7 @@ MPRPipelineResult MeasurementProvisioner::runPipeline ( const MPPipeline & pipel
if ( WEXITSTATUS ( status ) != 0 ) {
pipelineFinalResults.pipelineStatus.exitCode = WEXITSTATUS ( status );
pipelineFinalResults.pipelineStatus.errorOrigin = mppcIter->getRawCommand ( );
pipelineFinalResults.pipelineStatus.errorValue = pre.retrievePipelineError ( );
pipelineFinalResults.pipelineStatus.errorValue = pre.retrievePipelineError ( );
break;
}
 
......@@ -181,15 +181,15 @@ MeasurementProvisioner::PipelineRunnerEnvironment::PipelineRunnerEnvironment ( )
throw::exception::CommonException ( "MeasurementProvisioner: Cannot open measurements file descriptor" );
 
try {
inputTmpfile = MPUtils::openShmFile ( );
inputTmpfile = MPUtils::openShmFile ( );
outputTmpfile = MPUtils::openShmFile ( );
errorTmpfile = MPUtils::openShmFile ( );
errorTmpfile = MPUtils::openShmFile ( );
} catch ( ::exception::CommonException & ) {
throw::exception::CommonException ( "MeasurementProvisioner: Cannot make io tmp files" );
}
 
// store handles to stdin, stdout, stderr, we will need to restore them later
stdinFd = dup ( 0 );
stdinFd = dup ( 0 );
stdoutFd = dup ( 1 );
stderrFd = dup ( 2 );
 
......@@ -213,9 +213,8 @@ MeasurementProvisioner::PipelineRunnerEnvironment::~PipelineRunnerEnvironment (
close ( 1 );
close ( 2 );
 
dup ( stdinFd );
dup ( stdoutFd );
dup ( stderrFd );
if ( ( dup ( stdinFd ) == -1 ) || ( dup ( stdoutFd ) == -1 ) || ( dup ( stderrFd ) == -1 ) )
throw::exception::CommonException ( "MeasurementProvisioner: dup failed" );
 
close ( stdinFd );
close ( stdoutFd );
......@@ -224,27 +223,27 @@ MeasurementProvisioner::PipelineRunnerEnvironment::~PipelineRunnerEnvironment (
 
void MeasurementProvisioner::PipelineRunnerEnvironment::commandFdInit ( ) {
// sets the right file descriptors for child processes - commands
dup ( inputTmpfile.fd );
dup ( outputTmpfile.fd );
dup ( errorTmpfile.fd );
if ( ( dup ( inputTmpfile.fd ) == -1 ) || ( dup ( outputTmpfile.fd ) == -1 ) || ( dup ( errorTmpfile.fd ) == -1 ) )
throw::exception::CommonException ( "MeasurementProvisioner: dup failed" );
}
 
void MeasurementProvisioner::PipelineRunnerEnvironment::commandFdSwap ( ) {
// swap stdin and stdout for next command
close ( 0 );
close ( 1 );
if ( dup ( outputTmpfile.fd ) == -1 || dup ( inputTmpfile.fd ) == -1) {
if ( ( dup ( outputTmpfile.fd ) == -1 ) || ( dup ( inputTmpfile.fd ) == -1 ) )
throw::exception::CommonException ( "MeasurementProvisioner: dup failed" );
}
 
// rewind previous stdout to the beginning, so the next command can read the whole file as input
lseek ( 0, 0, SEEK_SET );
 
// destroy the contents of previous stdin and rewind to the beginning
lseek ( 1, 0, SEEK_SET );
if(ftruncate ( 1, 0 ) == -1) {
if ( ftruncate ( 1, 0 ) == -1 )
throw::exception::CommonException ( "MeasurementProvisioner: ftruncate failed" );
}
}
 
void MeasurementProvisioner::PipelineRunnerEnvironment::commandFdEnd ( ) {
......@@ -280,7 +279,9 @@ MeasurementResults MeasurementProvisioner::PipelineRunnerEnvironment::retrieveMe
 
// destroy the contents and rewind for another commands measurements
lseek ( measurementsFd, 0, SEEK_SET );
ftruncate ( measurementsFd, 0 );
if ( ftruncate ( measurementsFd, 0 ) == -1 )
throw::exception::CommonException ( "MeasurementProvisioner: ftruncate failed" );
 
return measurements::MeasurementResultsXml::parse ( tokens );
}
......
......@@ -73,14 +73,22 @@ std::string MPUtils::generateTmpfileFromCommand ( const std::string & command )
 
int stdoutfd = dup ( 1 );
 
if ( stdoutfd == -1 )
throw::exception::CommonException ( "MeasurementProvisionerUtils: dup failed" );
close ( 1 );
dup ( tempShmFile.fd );
if ( dup ( tempShmFile.fd ) == -1 )
throw::exception::CommonException ( "MeasurementProvisionerUtils: dup failed" );
 
int status = system ( command.c_str ( ) );
 
close ( 1 );
close ( tempShmFile.fd );
dup ( stdoutfd );
if ( dup ( stdoutfd ) == -1 )
throw::exception::CommonException ( "MeasurementProvisionerUtils: dup failed" );
close ( stdoutfd );
 
if ( WEXITSTATUS ( status ) != 0 ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment