library/src/blockclass/subclasses/command_line_tools/BP_CommandLineToolBase.cc
// Execute application.  This will populate some local data, so before
// calling it recursively, call the cleanup routine below, or just delete
// and recreate the object.  Performance hits should be negligable either way.
//
// You can also reimplement this function to meet the needs of the command you
// are executing so long as you satisfy basic requirements.
Execute application.  This will populate some local data, so before
calling it recursively, call the cleanup routine below, or just delete
and recreate the object.  Performance hits should be negligable either way.

You can also reimplement this function to meet the needs of the command you
are executing so long as you satisfy basic requirements.
Execute application . This will populate some local data so before calling it recursively call the cleanup routine below or just delete and recreate the object . Performance hits should be negligable either way . You can also reimplement this function to meet the needs of the command you are executing so long as you satisfy basic requirements .
BP_ERROR_T BP_CommandLineToolBase::executeApplicationBinary
(
		size_t poll_read_timeout,
		size_t poll_read_timeout_stderr,
		BP_BOOL display_reads,
		BP_BOOL display_writes
)
{
	if(!this->application_path_to_bin)
	{
		printf("\n [!!] Error: Using Application interface requires path to binary.");
		return ERR_FAILURE;
	}
	if(!this->application_args)
	{
		printf("\n [!!] Error: Application Module Requires parameters to run.");
		return ERR_FAILURE;
	}
	if(!this->application_envp)
	{
		printf("\n [!!] Error: Application Module requires an ENVP set.  You can just pass in the one from main().");
		return ERR_FAILURE;
	}
	this->File_Execute(this->application_args[0], this->application_args, this->application_envp, BP_TRUE);
	BP_FSetNonBlockingIO(this->fdSet);
	this->ccNewSession(this->fdSet, "Application Command And Control Module", BP_CC_SHELL_LINUX_EXECVE);
	this->cc_session->display_reads_from_app_stdout = display_reads;
	this->cc_session->display_reads_from_app_stderr = display_reads;
	this->cc_session->display_writes_to_app_stdin   = display_writes;
	this->cc_session->poll_timeout        = poll_read_timeout;
	this->cc_session->poll_timeout_stderr = poll_read_timeout_stderr;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_CommandLineToolBase :: executeApplicationBinary ( size_t poll_read_timeout , size_t poll_read_timeout_stderr , BP_BOOL display_reads , BP_BOOL display_writes ) { if ( ! this -> application_path_to_bin ) { printf ( " \n " ) ; return ERR_FAILURE ; } if ( ! this -> application_args ) { printf ( " \n " ) ; return ERR_FAILURE ; } if ( ! this -> application_envp ) { printf ( " \n " ) ; return ERR_FAILURE ; } this -> File_Execute ( this -> application_args [ 0 ] , this -> application_args , this -> application_envp , BP_TRUE ) ; BP_FSetNonBlockingIO ( this -> fdSet ) ; this -> ccNewSession ( this -> fdSet , " " , BP_CC_SHELL_LINUX_EXECVE ) ; this -> cc_session -> display_reads_from_app_stdout = display_reads ; this -> cc_session -> display_reads_from_app_stderr = display_reads ; this -> cc_session -> display_writes_to_app_stdin = display_writes ; this -> cc_session -> poll_timeout = poll_read_timeout ; this -> cc_session -> poll_timeout_stderr = poll_read_timeout_stderr ; return ERR_SUCCESS ; }
Execute application.
Execute application .
// ensure we have a path to the binary // ensure we have arguments // execute the program // set nonblocking io on the program // create new cc session // set monitoring flags // set polling timeouts // return indicating success