From 550b5257aba507bcce98f6832b8905769a14955d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Apr 2017 13:19:19 +0200 Subject: Add process_run()/process_start() higher-level API on top of class process --- butl/process.cxx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'butl/process.cxx') diff --git a/butl/process.cxx b/butl/process.cxx index 189d1ee..74892e6 100644 --- a/butl/process.cxx +++ b/butl/process.cxx @@ -64,7 +64,7 @@ namespace butl process_path r (try_path_search (f, init, fb)); if (r.empty ()) - throw process_error (ENOENT, false); + throw process_error (ENOENT); return r; } @@ -259,7 +259,13 @@ namespace butl fdpipe in_ofd; fdpipe in_efd; - auto fail = [] (bool child) {throw process_error (errno, child);}; + auto fail = [] (bool child) + { + if (child) + throw process_child_error (errno); + else + throw process_error (errno); + }; auto open_pipe = [] () -> fdpipe { @@ -276,7 +282,7 @@ namespace butl // other hand the only possible values are EMFILE and ENFILE. Lets use // EMFILE as the more probable. This is a temporary code after all. // - throw process_error (EMFILE, false); + throw process_error (EMFILE); } }; @@ -391,7 +397,7 @@ namespace butl // information available" semantics. // if (!ie) - throw process_error (errno, false); + throw process_error (errno); } else exit = process_exit (es, process_exit::as_status); @@ -401,7 +407,7 @@ namespace butl } bool process:: - try_wait (bool& s) + try_wait () { if (handle != 0) { @@ -414,12 +420,11 @@ namespace butl handle = 0; // We have tried. if (r == -1) - throw process_error (errno, false); + throw process_error (errno); exit = process_exit (es, process_exit::as_status); } - s = exit && exit->normal () && exit->code () == 0; return true; } @@ -1089,7 +1094,7 @@ namespace butl } bool process:: - try_wait (bool& s) + try_wait () { if (handle != 0) { @@ -1112,7 +1117,6 @@ namespace butl exit->status = es; } - s = exit && exit->normal () && exit->code () == 0; return true; } -- cgit v1.1