diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-10-25 10:24:53 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2022-10-25 17:30:37 +0300 |
commit | b7f32cea30174e391027fecc9d431ca16b2f87c2 (patch) | |
tree | e9fe8c29bf361fa96b9a79243bffde0d1405b6e8 /libbutl/process.ixx | |
parent | 397d710073eae9ad282bc0df9482a41d621acde5 (diff) |
All passing to process ownership to one end of pipe
Diffstat (limited to 'libbutl/process.ixx')
-rw-r--r-- | libbutl/process.ixx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libbutl/process.ixx b/libbutl/process.ixx index 256454b..0f04127 100644 --- a/libbutl/process.ixx +++ b/libbutl/process.ixx @@ -124,6 +124,42 @@ namespace butl } #endif + // process::pipe + // + inline process::pipe:: + pipe (pipe&& p) + : in (p.in), out (p.out), own_in (p.own_in), own_out (p.own_out) + { + p.in = p.out = -1; + } + + inline process::pipe& process::pipe:: + operator= (pipe&& p) + { + if (this != &p) + { + int d (own_in ? in : own_out ? out : -1); + if (d != -1) + fdclose (d); + + in = p.in; + out = p.out; + own_in = p.own_in; + own_out = p.own_out; + + p.in = p.out = -1; + } + return *this; + } + + inline process::pipe:: + ~pipe () + { + int d (own_in ? in : own_out ? out : -1); + if (d != -1) + fdclose (d); + } + // process // #ifndef _WIN32 |