20 std::string
const& executableStringIncludingArguments,
22 int const patienceMilliseconds ) :
24 isVerbose( isVerbose ),
25 executableNameAndArguments( 0 ),
26 argumentListAsArray( NULL ),
27 patienceTicks( ( ( patienceMilliseconds * CLOCKS_PER_SEC ) / 1000 ) ),
52 int processStatus( 0 );
56 bool subprocessReturned(
true );
58 int forkReturnValue( fork() );
59 if( 0 > forkReturnValue )
64 <<
"BOL::error! WaitingOnSubprocessExecutor::forkAndExecvAndWait() was"
65 <<
" unable to create the subprocess; there was an error and fork()"
66 <<
" returned " << forkReturnValue << std::endl;
69 else if( 0 == forkReturnValue )
79 for(
int argumentWritingCounter( 1 );
81 ++argumentWritingCounter )
87 <<
"\", with process id " << getpid() <<
", real user id " << getuid()
88 <<
" & effective user id " << geteuid() << std::endl;
95 else if( 0 < forkReturnValue )
99 bool subprocessFinished(
false );
103 if( waitpid( forkReturnValue,
105 WNOHANG ) == forkReturnValue )
113 subprocessFinished =
true;
122 if(
false == subprocessFinished )
130 <<
"killing forked process " << forkReturnValue
131 <<
" due to it taking over " <<
patienceTicks <<
" milliseconds"
135 kill( forkReturnValue,
142 subprocessReturned =
false;
146 returnValue = WEXITSTATUS( processStatus );
148 return subprocessReturned;
static void parseByChar(std::string const &stringToParse, VectorlikeArray< std::string > &destinationArray, std::string const &divisionCharSet=whitespaceChars)
void setUpArgumentCharArray()
static int const sleepingMicroseconds
char const ** argumentListAsArray
VectorlikeArray< std::string > executableNameAndArguments
bool forkAndExecvAndWait()
WaitingOnSubprocessExecutor(std::string const &executableStringIncludingArguments, bool const isVerbose, int const patienceMilliseconds=10000)
~WaitingOnSubprocessExecutor()