From 21a271ad96d1be5653c94fa81e32fcf3e2a957f1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Nov 2015 12:49:06 +0200 Subject: Make process move-assignable, add default c-tor --- butl/process.ixx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'butl/process.ixx') diff --git a/butl/process.ixx b/butl/process.ixx index a049764..baf55f8 100644 --- a/butl/process.ixx +++ b/butl/process.ixx @@ -5,6 +5,16 @@ namespace butl { inline process:: + process () + : id (0), + status (0), // This is a bit of an assumption. + out_fd (-1), + in_ofd (-1), + in_efd (-1) + { + } + + inline process:: process (char const* const args[], int in, int out, int err) : process (nullptr, args, in, out, err) {} @@ -22,4 +32,24 @@ namespace butl { p.id = 0; } + + inline process& process:: + operator= (process&& p) + { + if (this != &p) + { + if (id != 0) + wait (); + + id = p.id; + status = p.status; + out_fd = p.out_fd; + in_ofd = p.in_ofd; + in_efd = p.in_efd; + + p.id = 0; + } + + return *this; + } } -- cgit v1.1