38#ifndef BLOCXX_EXEC_HPP_INCLUDE_GUARD_
39#define BLOCXX_EXEC_HPP_INCLUDE_GUARD_
41#include "blocxx/BLOCXX_config.h"
45#ifdef BLOCXX_ENABLE_TEST_HOOKS
87 template <
typename SA1,
typename SA2>
98 const char*
const envp[] = 0) BLOCXX_DEPRECATED;
126 enum { MAX_MSG_LEN = 64 };
127 char message[MAX_MSG_LEN + 1];
166 void closeDescriptorsOnExec(std::vector<bool>
const &
keep);
172 static void resetSignals();
197 static void setNewProcessGroup();
231 char const *
const argv[],
char const *
const envp[],
246 template <
typename S,
typename SA1,
typename SA2>
261 char const *
const argv[],
char const *
const envp[]
271 template <
typename SA1,
typename SA2>
281 template <
typename SA1>
357 : m_running(E_PROCESS_RUNNING)
362 explicit ProcessStatus(
int status)
363 : m_running(E_PROCESS_EXITED)
368 bool hasExited()
const
370 return m_running == E_PROCESS_EXITED;
373 const int& getStatus()
const
378 EProcessRunning m_running;
452 String
const &
input = String());
496 String
const &
input = String());
531 char const *
input = 0);
569 char const *
input = 0);
575 template <
typename SA1,
typename S1,
typename S2>
603 template <
typename SA1,
typename S1,
typename S2>
632 template <
typename SA1,
typename S1>
659 template <
typename SA1,
typename S1>
697 template <
typename SA1,
typename S1,
typename SA2,
typename S2>
735 template <
typename SA1,
typename S1,
typename SA2,
typename S2>
765 template <
typename SA1,
typename S1,
typename SA2>
800#ifdef BLOCXX_ENABLE_TEST_HOOKS
#define BLOCXX_DECLARE_APIEXCEPTION(NAME, LINKAGE_SPEC)
Declare a new exception class named <NAME>Exception that derives from Exception This macro is typical...
#define BLOCXX_DECLARE_APIEXCEPTION2(NAME, BASE, LINKAGE_SPEC)
Declare a new exception class named <NAME>Exception that derives from <BASE>.
Array<> wraps std::vector<> in COWReference<> adding ref counting and copy on write capability.
virtual void doHandleData(const char *data, size_t dataLen, EOutputSource outputSource, const ProcessRef &theProc, size_t streamIndex, Array< char > &inputBuffer)=0
This class is used to specify what spawn() should do between fork and exec.
::BLOCXX_NAMESPACE::UnnamedPipe * pipe_pointer_t
virtual void call(pipe_pointer_t const pparr[])=0
This function is called between fork and exec in the spawn() function.
virtual bool keepStd(int d) const =0
This class can be used to store a global pointer.
This String class is an abstract data type that represents as NULL terminated string of characters.
A timeout can be absolute, which means that it will happen at the specified DateTime.
Abstract interface for an UnnamedPipe.
char const * to_char_ptr(S const &s)
unsigned const BLOCXX_OUT
unsigned const BLOCXX_NPIPE
void close_child_ends(UnnamedPipeRef ppipe[BLOCXX_NPIPE])
unsigned const BLOCXX_EXEC_ERR
unsigned const BLOCXX_SERR
int safeSystem(const Array< String > &command, const char *const envp[])
This is deprecated.
Process::Status executeProcessAndGatherOutput(char const *const command[], String &output, char const *const envVars[], const Timeout &timeout, int outputLimit, char const *input)
Execute a command and run feedProcessAndGatherOutput() on the process.
ProcessRef spawn(char const *exec_path, char const *const argv[], char const *const envp[], PreExec &pre_exec)
Run the executable exec_path in a child process, with argv for the program arguments and envp for the...
void processInputOutput(OutputCallback &output, Array< ProcessRef > &procs, InputCallback &input, const Timeout &timeout)
Send input and wait for output from child processes.
Process::Status feedProcessAndGatherOutput(ProcessRef const &proc, String &output, Timeout const &timeout, int outputLimit, String const &input)
Send input to a process, collect the output, and wait for it to exit.
static char const *const *const currentEnvironment
Intended to be used as a parameter to spawn() to indicate that the current environment will be used f...
::BLOCXX_NAMESPACE::GlobalPtr< ExecMockObject, Impl::NullFactory > g_execMockObject
Process::Status system(const Array< String > &command, const char *const envp[], const Timeout &timeout)
Execute a command.
void gatherOutput(String &output, const ProcessRef &proc, int timeoutSecs, int outputLimit)
IntrusiveReference< Process > ProcessRef
bool operator==(const Array< T > &x, const Array< T > &y)
Class for converting values of type S into char const * const *.
Use this class to allow call() to throw an exception.