.. index:: pair: class; EE::System::Process .. _doxid-class_e_e_1_1_system_1_1_process: class EE::System::Process ========================= .. toctree:: :hidden: enum_EE_System_Process_Options.rst struct_EE_System_Process_Config.rst Overview ~~~~~~~~ .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class Process { public: // typedefs typedef std::function :target:`ReadFn`; // enums enum :ref:`Options`; // structs struct :ref:`Config`; // construction :target:`Process`(); :ref:`Process`(const std::string& command, :ref:`Uint32` options = :ref:`getDefaultOptions`(), const std::unordered_map& environment = {}, const std::string& workingDirectory = "", const size_t& bufferSize = 132072); :target:`~Process`(); // methods static constexpr :ref:`Uint32` :target:`getDefaultOptions`(); bool :ref:`create`(const std::string& command, :ref:`Uint32` options = :ref:`getDefaultOptions`(), const std::unordered_map& environment = {}, const std::string& workingDirectory = ""); bool :ref:`create`(const std::string& command, const std::string& args, :ref:`Uint32` options = :ref:`getDefaultOptions`(), const std::unordered_map& environment = {}, const std::string& workingDirectory = ""); bool :ref:`create`(const std::string& command, const std::vector& args, :ref:`Uint32` options = :ref:`getDefaultOptions`(), const std::unordered_map& environment = {}, const std::string& workingDirectory = ""); void :ref:`startAsyncRead`(:ref:`ReadFn` readStdOut = nullptr, :ref:`ReadFn` readStdErr = nullptr); size_t :ref:`readAllStdOut`(std::string& buffer, :ref:`Time` timeout = :ref:`Time::Zero`); size_t :ref:`readStdOut`(std::string& buffer); size_t :ref:`readStdOut`(char*const buffer, const size_t& size); size_t :ref:`readAllStdErr`(std::string& buffer, :ref:`Time` timeout = :ref:`Time::Zero`); size_t :ref:`readStdErr`(std::string& buffer); size_t :ref:`readStdErr`(char*const buffer, const size_t& size); size_t :ref:`write`(const char* buffer, const size_t& size); size_t :ref:`write`(const std::string& buffer); size_t :ref:`write`(const std::string_view& buffer); bool :ref:`join`(int*const returnCodeOut); bool :ref:`kill`(); bool :ref:`destroy`(); bool :ref:`isAlive`(); FILE* :ref:`getStdIn`() const; FILE* :ref:`getStdOut`() const; FILE* :ref:`getStdErr`() const; void :ref:`startShutdown`(); const bool& :ref:`isShuttingDown`(); }; .. _details-class_e_e_1_1_system_1_1_process: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Construction ------------ .. index:: pair: function; Process .. _doxid-class_e_e_1_1_system_1_1_process_1aefbd0bf633b74f02ba912f7b938c68c4: .. ref-code-block:: cpp :class: doxyrest-title-code-block Process(const std::string& command, :ref:`Uint32` options = :ref:`getDefaultOptions`(), const std::unordered_map& environment = {}, const std::string& workingDirectory = "", const size_t& bufferSize = 132072) Create a process. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - command - Command line to execute for this process. * - options - A bit field of Options's to pass. Methods ------- .. index:: pair: function; create .. _doxid-class_e_e_1_1_system_1_1_process_1a5ec873c968104ba935c15a46519e8072: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool create(const std::string& command, :ref:`Uint32` options = :ref:`getDefaultOptions`(), const std::unordered_map& environment = {}, const std::string& workingDirectory = "") Create a process. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - command - Command line to execute for this process. * - options - A bit field of Options's to pass. .. rubric:: Returns: On success true is returned. .. index:: pair: function; create .. _doxid-class_e_e_1_1_system_1_1_process_1ab8bae96aa1bf7ed134ec5e6e036e2163: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool create(const std::string& command, const std::string& args, :ref:`Uint32` options = :ref:`getDefaultOptions`(), const std::unordered_map& environment = {}, const std::string& workingDirectory = "") Create a process. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - command - Command line to execute for this process. * - args - Command line arguments to execute for this process. * - options - A bit field of Options's to pass. .. rubric:: Returns: On success true is returned. .. index:: pair: function; create .. _doxid-class_e_e_1_1_system_1_1_process_1a2b4d154d37e8a213973bdc2e64240101: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool create(const std::string& command, const std::vector& args, :ref:`Uint32` options = :ref:`getDefaultOptions`(), const std::unordered_map& environment = {}, const std::string& workingDirectory = "") Create a process. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - command - Command line to execute for this process. * - args - Command line arguments to execute for this process. * - options - A bit field of Options's to pass. .. rubric:: Returns: On success true is returned. .. index:: pair: function; startAsyncRead .. _doxid-class_e_e_1_1_system_1_1_process_1a1293cdcd7ec15b7fd49586686bb6c187: .. ref-code-block:: cpp :class: doxyrest-title-code-block void startAsyncRead(:ref:`ReadFn` readStdOut = nullptr, :ref:`ReadFn` readStdErr = nullptr) Starts a new thread to receive all stdout and stderr data. .. index:: pair: function; readAllStdOut .. _doxid-class_e_e_1_1_system_1_1_process_1a6ead0c96547691911d5ecae2ef89530a: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t readAllStdOut(std::string& buffer, :ref:`Time` timeout = :ref:`Time::Zero`) Read all standard output from the child process. The only safe way to read from the standard output of a process during it's execution is to use the ``Option::EnableAsync`` option in conjuction with this method. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to read into. .. rubric:: Returns: The number of bytes actually read into buffer. Can only be 0 if the process has complete. .. index:: pair: function; readStdOut .. _doxid-class_e_e_1_1_system_1_1_process_1a067ce94a4b0a6c58fd7fd56b32dbadec: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t readStdOut(std::string& buffer) Read the standard output from the child process. The only safe way to read from the standard output of a process during it's execution is to use the ``Option::EnableAsync`` option in conjuction with this method. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to read into. .. rubric:: Returns: The number of bytes actually read into buffer. Can only be 0 if the process has complete. .. index:: pair: function; readStdOut .. _doxid-class_e_e_1_1_system_1_1_process_1a01375a3beb1d2438eb9a4729ecd01719: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t readStdOut(char*const buffer, const size_t& size) Read the standard output from the child process. The only safe way to read from the standard output of a process during it's execution is to use the ``Option::EnableAsync`` option in conjuction with this method. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to read into. * - size - The maximum number of bytes to read. .. rubric:: Returns: The number of bytes actually read into buffer. Can only be 0 if the process has complete. .. index:: pair: function; readAllStdErr .. _doxid-class_e_e_1_1_system_1_1_process_1ac705b195ae299ad91fca55b97507b79b: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t readAllStdErr(std::string& buffer, :ref:`Time` timeout = :ref:`Time::Zero`) Read all the standard error from the child process. The only safe way to read from the standard error of a process during it's execution is to use the ``Option::EnableAsync`` option in conjuction with this method. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to read into. .. rubric:: Returns: The number of bytes actually read into buffer. Can only be 0 if the process has complete. .. index:: pair: function; readStdErr .. _doxid-class_e_e_1_1_system_1_1_process_1a8ed0248efaf5e4a6607fe92e94e8b5b6: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t readStdErr(std::string& buffer) Read the standard error from the child process. The only safe way to read from the standard error of a process during it's execution is to use the ``Option::EnableAsync`` option in conjuction with this method. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to read into. .. rubric:: Returns: The number of bytes actually read into buffer. Can only be 0 if the process has complete. .. index:: pair: function; readStdErr .. _doxid-class_e_e_1_1_system_1_1_process_1a156bb8eb3a65da24081d825dd4128aa4: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t readStdErr(char*const buffer, const size_t& size) Read the standard error from the child process. The only safe way to read from the standard error of a process during it's execution is to use the ``Option::EnableAsync`` option in conjuction with this method. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to read into. * - size - The maximum number of bytes to read. .. rubric:: Returns: The number of bytes actually read into buffer. Can only be 0 if the process has complete. .. index:: pair: function; write .. _doxid-class_e_e_1_1_system_1_1_process_1a76fbdc47ad1ba055dfe7e0ee453a5074: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t write(const char* buffer, const size_t& size) Write the standard output from the child process. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to write into. * - size - The number of bytes to write. .. rubric:: Returns: The number of bytes actually written into buffer. .. index:: pair: function; write .. _doxid-class_e_e_1_1_system_1_1_process_1a144dba38178ce0c6455ca878b226d54f: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t write(const std::string& buffer) Write the standard output from the child process. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to write into. .. rubric:: Returns: The number of bytes actually written into buffer. .. index:: pair: function; write .. _doxid-class_e_e_1_1_system_1_1_process_1a33d8028bfaa38e788f3c709f760a7a82: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t write(const std::string_view& buffer) Write the standard output from the child process. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - buffer - The buffer to write into. .. rubric:: Returns: The number of bytes actually written into buffer. .. index:: pair: function; join .. _doxid-class_e_e_1_1_system_1_1_process_1aceb3f67ef10f90bcb05694f9b79c5f43: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool join(int*const returnCodeOut) Wait for a process to finish execution. Joining a process will close the stdin pipe to the process. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - returnCodeOut - The return code of the returned process (can be nullptr). .. rubric:: Returns: On success true is returned. .. index:: pair: function; kill .. _doxid-class_e_e_1_1_system_1_1_process_1a54890a87e38db794b7e137adb559d9f0: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool kill() Terminate a previously created process. If the process to be destroyed had not finished execution, it will be terminated (i.e killed). .. rubric:: Returns: On success true is returned. .. index:: pair: function; destroy .. _doxid-class_e_e_1_1_system_1_1_process_1afb1545a0c1ad85546c852dbe945dd341: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool destroy() Destroy a previously created process. If the process to be destroyed had not finished execution, it may out live the parent process. .. rubric:: Returns: On success true is returned. .. index:: pair: function; isAlive .. _doxid-class_e_e_1_1_system_1_1_process_1aaec4ea9088a547a2ba2f193de6a77229: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool isAlive() Returns if the subprocess is currently still alive and executing. .. rubric:: Returns: If the process is still alive true returned. .. index:: pair: function; getStdIn .. _doxid-class_e_e_1_1_system_1_1_process_1a3e60ff5c9e519cc0a958b4e4fbef5ae3: .. ref-code-block:: cpp :class: doxyrest-title-code-block FILE* getStdIn() const Get the standard input file for a process. The file returned can be written to by the parent process to feed data to the standard input of the process. .. rubric:: Returns: The file for standard input of the process. .. index:: pair: function; getStdOut .. _doxid-class_e_e_1_1_system_1_1_process_1ac46362635db1ba77ebef533d1f8f1e3a: .. ref-code-block:: cpp :class: doxyrest-title-code-block FILE* getStdOut() const Get the standard output file for a process. The file returned can be read from by the parent process to read data from the standard output of the child process. .. rubric:: Returns: The file for standard output of the process. .. index:: pair: function; getStdErr .. _doxid-class_e_e_1_1_system_1_1_process_1a38e7738885e6923d37dd276214338099: .. ref-code-block:: cpp :class: doxyrest-title-code-block FILE* getStdErr() const Get the standard error file for a process. The file returned can be read from by the parent process to read data from the standard error of the child process. If the process was created with the Option::CombinedStdoutStderr option bit set, this function will return NULL, and the getStdOut function should be used for both the standard output and error combined. .. rubric:: Returns: The file for standard error of the process. .. index:: pair: function; startShutdown .. _doxid-class_e_e_1_1_system_1_1_process_1a6a70fcd05bb8a2744ff8f35942287f17: .. ref-code-block:: cpp :class: doxyrest-title-code-block void startShutdown() Indicates that the process must start its shutdown .. index:: pair: function; isShuttingDown .. _doxid-class_e_e_1_1_system_1_1_process_1a69fc7f94997dd817b2bbe6ab75e63e93: .. ref-code-block:: cpp :class: doxyrest-title-code-block const bool& isShuttingDown() Indicates if the process started its shutdown