From a128eb0961ccf820ff2142897795b48723d842bd Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 21 Oct 2016 20:02:35 +0300 Subject: Make process status optional --- butl/process | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'butl/process') diff --git a/butl/process b/butl/process index e1eea29..c69c306 100644 --- a/butl/process +++ b/butl/process @@ -16,6 +16,7 @@ #include #include +#include namespace butl { @@ -106,6 +107,16 @@ namespace butl class LIBBUTL_EXPORT process { public: +#ifndef _WIN32 + using handle_type = pid_t; + using id_type = pid_t; + using status_type = int; +#else + using handle_type = void*; // Win32 HANDLE + using id_type = std::uint32_t; // Win32 DWORD + using status_type = std::uint32_t; // Win32 DWORD +#endif + // Start another process using the specified command line. The default // values to the in, out and err arguments indicate that the child process // should inherit the parent process stdin, stdout, and stderr, @@ -202,10 +213,13 @@ namespace butl process (const process&) = delete; process& operator= (const process&) = delete; - // Create an empty or "already terminated" process. That is, handle is 0 - // and exit status is 0. + // Create an empty or "already terminated" process. By default the + // termination status is abnormal but you can change that. + // + // @@ Need to audit all calls (__attribute__((deprecated))). // - process (); + explicit + process (optional status = nullopt); // Resolve process' paths based on the initial path in args0. If recall // differs from initial, adjust args0 to point to the recall path. If @@ -274,22 +288,12 @@ namespace butl print (std::ostream&, const char* const args[], size_t n = 0); public: -#ifndef _WIN32 - using handle_type = pid_t; - using id_type = pid_t; - using status_type = int; -#else - using handle_type = void*; // Win32 HANDLE - using id_type = std::uint32_t; // Win32 DWORD - using status_type = std::uint32_t; // Win32 DWORD -#endif - static id_type current_id (); public: handle_type handle; - status_type status; + optional status; // Absence means terminated abnormally. int out_fd; // Write to this fd to send to the new process' stdin. int in_ofd; // Read from this fd to receive from the new process' stdout. -- cgit v1.1