aboutsummaryrefslogtreecommitdiff
path: root/libbutl/process.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbutl/process.cxx')
-rw-r--r--libbutl/process.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/libbutl/process.cxx b/libbutl/process.cxx
index e416807..1b8da98 100644
--- a/libbutl/process.cxx
+++ b/libbutl/process.cxx
@@ -262,7 +262,7 @@ namespace butl
{
// Note that there is a similar version for Win32.
- typedef path::traits_type traits;
+ using traits = path::traits_type;
size_t fn (strlen (f));
@@ -454,6 +454,15 @@ namespace butl
else if (err == -2)
in_efd.out = open_null ();
+ // If there is no user-supplied CWD and we have thread-specific override,
+ // use that instead of defaulting to the process-wide value.
+ //
+ if (cwd == nullptr || *cwd == '\0')
+ {
+ if (const string* twd = path::traits_type::thread_current_directory ())
+ cwd = twd->c_str ();
+ }
+
const char* const* tevars (thread_env ());
// The posix_spawn()-based implementation.
@@ -1392,6 +1401,15 @@ namespace butl
throw process_error (m == nullptr ? last_error_msg () : m);
};
+ // If there is no user-supplied CWD and we have thread-specific override,
+ // use that instead of defaulting to the process-wide value.
+ //
+ if (cwd == nullptr || *cwd == '\0')
+ {
+ if (const string* twd = path::traits_type::thread_current_directory ())
+ cwd = twd->c_str ();
+ }
+
// (Un)set the environment variables for the child process.
//
// Note that we can not do it incrementally, as for POSIX implementation.