summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/Host/macosx/Host.mm11
-rw-r--r--lldb/test/functionalities/process_launch/TestProcessLaunch.py15
2 files changed, 22 insertions, 4 deletions
diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm
index 50afa2f8edc..0aea4a6bf03 100644
--- a/lldb/source/Host/macosx/Host.mm
+++ b/lldb/source/Host/macosx/Host.mm
@@ -1532,7 +1532,16 @@ LaunchProcessPosixSpawn (const char *exe_path, ProcessLaunchInfo &launch_info, :
if (working_dir)
{
// No more thread specific current working directory
- __pthread_chdir (working_dir);
+ if (__pthread_chdir (working_dir) < 0) {
+ if (errno == ENOENT) {
+ error.SetErrorStringWithFormat("No such file or directory: %s", working_dir);
+ } else if (errno == ENOTDIR) {
+ error.SetErrorStringWithFormat("Path doesn't name a directory: %s", working_dir);
+ } else {
+ error.SetErrorStringWithFormat("An unknown error occurred when changing directory for process execution.");
+ }
+ return error;
+ }
}
const size_t num_file_actions = launch_info.GetNumFileActions ();
diff --git a/lldb/test/functionalities/process_launch/TestProcessLaunch.py b/lldb/test/functionalities/process_launch/TestProcessLaunch.py
index 2a735634e3c..7cc1bebbad5 100644
--- a/lldb/test/functionalities/process_launch/TestProcessLaunch.py
+++ b/lldb/test/functionalities/process_launch/TestProcessLaunch.py
@@ -48,7 +48,7 @@ class ProcessLaunchTestCase(TestBase):
pass
launch_command = "process launch -i " + in_file + " -o " + out_file + " -e " + err_file
-
+
self.expect (launch_command,
patterns = [ "Process .* launched: .*a.out" ])
@@ -69,7 +69,7 @@ class ProcessLaunchTestCase(TestBase):
success = False
err_msg = err_msg + " ERROR: stdout file does not contain correct output.\n"
out_f.close();
-
+
# Try to delete the 'stdout' file
try:
os.remove (out_file)
@@ -139,6 +139,15 @@ class ProcessLaunchTestCase(TestBase):
except OSError:
pass
+ # Check that we get an error when we have a nonexisting path
+ launch_command = "process launch -w %s -o %s -e %s" % (my_working_dir_path + 'z',
+ out_file_path,
+ err_file_path)
+
+ self.expect(launch_command, error=True,
+ startstr = "error: No such file or directory: %sz" % my_working_dir_path)
+
+ # Really launch the process
launch_command = "process launch -w %s -o %s -e %s" % (my_working_dir_path,
out_file_path,
err_file_path)
@@ -164,7 +173,7 @@ class ProcessLaunchTestCase(TestBase):
success = False
err_msg = err_msg + "The current working directory was not set correctly.\n"
out_f.close();
-
+
# Try to delete the 'stdout' and 'stderr' files
try:
os.remove(out_file_path)
OpenPOWER on IntegriCloud