From 4966830d337556363dbef3c5c7e3fb8763c5cd75 Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 8 May 2017 18:42:30 +0200 Subject: [PATCH] rename process_info to subprocess --- build.cc | 6 +++--- ostd/process.hh | 14 +++++++------- src/process.cc | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/build.cc b/build.cc index 105d2cf..268fd77 100644 --- a/build.cc +++ b/build.cc @@ -111,9 +111,9 @@ static void print_help(ostd::string_range arg0) { } static void exec_command(strvec const &args) { - ostd::process_info pi; - pi.open_command(ostd::iter(args)); - if (int ret; (ret = pi.close())) { + ostd::subprocess p; + p.open_command(ostd::iter(args)); + if (int ret; (ret = p.close())) { auto app = ostd::appender(); ostd::format(app, "command failed with code %d", ret); throw std::runtime_error{app.get()}; diff --git a/ostd/process.hh b/ostd/process.hh index f52d3bb..a2683af 100644 --- a/ostd/process.hh +++ b/ostd/process.hh @@ -86,7 +86,7 @@ enum class process_stream { STDOUT }; -struct OSTD_EXPORT process_info { +struct OSTD_EXPORT subprocess { process_stream use_in = process_stream::DEFAULT; process_stream use_out = process_stream::DEFAULT; process_stream use_err = process_stream::DEFAULT; @@ -94,14 +94,14 @@ struct OSTD_EXPORT process_info { file_stream out = file_stream{}; file_stream err = file_stream{}; - process_info() {} - process_info( + subprocess() {} + subprocess( process_stream in_use, process_stream out_use, process_stream err_use ): use_in(in_use), use_out(out_use), use_err(err_use) {} - process_info(process_info &&i): + subprocess(subprocess &&i): use_in(i.use_in), use_out(i.use_out), use_err(i.use_err), in(std::move(i.in)), out(std::move(i.out)), err(std::move(i.err)), pid(i.pid), errno_fd(i.errno_fd) @@ -110,12 +110,12 @@ struct OSTD_EXPORT process_info { i.errno_fd = -1; } - process_info &operator=(process_info &&i) { + subprocess &operator=(subprocess &&i) { swap(i); return *this; } - void swap(process_info &i) { + void swap(subprocess &i) { using std::swap; swap(use_in, i.use_in); swap(use_out, i.use_out); @@ -127,7 +127,7 @@ struct OSTD_EXPORT process_info { swap(errno_fd, i.errno_fd); } - ~process_info(); + ~subprocess(); int close(); diff --git a/src/process.cc b/src/process.cc index 0a7a529..0de082c 100644 --- a/src/process.cc +++ b/src/process.cc @@ -181,7 +181,7 @@ struct pipe { } }; -OSTD_EXPORT void process_info::open_impl( +OSTD_EXPORT void subprocess::open_impl( std::string const &cmd, std::vector const &args, bool use_path ) { @@ -266,14 +266,14 @@ OSTD_EXPORT void process_info::open_impl( } } -OSTD_EXPORT void process_info::reset() { +OSTD_EXPORT void subprocess::reset() { pid = -1; if (errno_fd >= 0) { ::close(std::exchange(errno_fd, -1)); } } -OSTD_EXPORT int process_info::close() { +OSTD_EXPORT int subprocess::close() { if (pid < 0) { reset(); throw process_error{ECHILD, std::generic_category()}; @@ -296,7 +296,7 @@ OSTD_EXPORT int process_info::close() { return retc; } -OSTD_EXPORT process_info::~process_info() { +OSTD_EXPORT subprocess::~subprocess() { try { close(); } catch (process_error const &) {} @@ -305,17 +305,17 @@ OSTD_EXPORT process_info::~process_info() { #else /* OSTD_PLATFORM_WIN32 */ -OSTD_EXPORT void process_info::open_impl( +OSTD_EXPORT void subprocess::open_impl( std::string const &, std::vector const &, bool ) { return; } -OSTD_EXPORT int process_info::close() { +OSTD_EXPORT int subprocess::close() { throw process_error{ECHILD, std::generic_category()}; } -OSTD_EXPORT process_info::~process_info() { +OSTD_EXPORT subprocess::~subprocess() { return; }