From cdc67ad0cf1e102568396b0649dd18ea1223d785 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 25 Sep 2015 15:25:50 +0200 Subject: Ignore empty cwd in process --- butl/process | 3 ++- butl/process.cxx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/butl/process b/butl/process index bb77684..bbd0162 100644 --- a/butl/process +++ b/butl/process @@ -60,7 +60,8 @@ namespace butl process (char const* const args[], process& in, int out = 1, int err = 2); // Versions of the above constructors that allow us to change the - // current working directory of the child process. + // current working directory of the child process. NULL and empty + // cwd arguments are ignored. // process (const char* cwd, char const* const[], int = 0, int = 1, int = 2); process (const char* cwd, char const* const[], process&, int = 1, int = 2); diff --git a/butl/process.cxx b/butl/process.cxx index 3556fd9..66a831e 100644 --- a/butl/process.cxx +++ b/butl/process.cxx @@ -76,7 +76,7 @@ namespace butl // Change current working directory if requested. // - if (cwd != nullptr && chdir (cwd) != 0) + if (cwd != nullptr && *cwd != '\0' && chdir (cwd) != 0) throw process_error (errno, true); if (execvp (args[0], const_cast (&args[0])) == -1) -- cgit v1.1