diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-07-12 17:24:00 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-07-23 19:42:48 +0300 |
commit | 6c8e3f09c185d7fa4664ccd9e5c4f623a17b84cc (patch) | |
tree | 513f523dba31f275994d8152c02db82f3380c56e /butl/process.cxx | |
parent | 09bedede7116961fbfb298a6a6cfa933af7af682 (diff) |
Extend fdstream
Diffstat (limited to 'butl/process.cxx')
-rw-r--r-- | butl/process.cxx | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/butl/process.cxx b/butl/process.cxx index e67e12e..9bb0ea2 100644 --- a/butl/process.cxx +++ b/butl/process.cxx @@ -196,7 +196,7 @@ namespace butl } bool process:: - wait () + wait (bool ie) { if (handle != 0) { @@ -204,7 +204,18 @@ namespace butl handle = 0; // We have tried. if (r == -1) - throw process_error (errno, false); + { + if (!ie) + throw process_error (errno, false); + else + // Fold into status, so this and subsequent wait() calls return + // false. There is no portable way to update the status bits + // representing a process exit code specifically. So we set all bits + // to 1 and recon on getting non-zero exit status wherever the exact + // bits are. + // + status = ~0; + } } return WIFEXITED (status) && WEXITSTATUS (status) == 0; @@ -571,7 +582,7 @@ namespace butl } bool process:: - wait () + wait (bool ie) { if (handle != 0) { @@ -584,10 +595,15 @@ namespace butl auto_handle h (handle); // Auto-deleter. handle = 0; // We have tried. - if (e != NO_ERROR) - throw process_error (error_msg (e)); - - status = s; + if (e == NO_ERROR) + status = s; + else + { + if (!ie) + throw process_error (error_msg (e)); + else + status = 1; // Fold into status. + } } return status == 0; |