From ca92aed5dc6301ff1bf642fdc44d8b344106e98a Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 7 Jul 2016 15:46:00 +0000 Subject: [LLGS] Work around an adb bug on Android <=M On android M it can happen that we get a ETXTBSY, when we try to launch the inferior. Sleeping and retrying should help us get more stable results. llvm-svn: 274763 --- lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp') diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp index bbd24ea65554..eb7b07bb5c60 100644 --- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -561,6 +561,18 @@ NativeProcessLinux::ChildFunc(const LaunchArgs &args) // Execute. We should never return... execve(args.m_argv[0], const_cast(args.m_argv), const_cast(envp)); + if (errno == ETXTBSY) + { + // On android M and earlier we can get this error because the adb deamon can hold a write + // handle on the executable even after it has finished uploading it. This state lasts + // only a short time and happens only when there are many concurrent adb commands being + // issued, such as when running the test suite. (The file remains open when someone does + // an "adb shell" command in the fork() child before it has had a chance to exec.) Since + // this state should clear up quickly, wait a while and then give it one more go. + usleep(10000); + execve(args.m_argv[0], const_cast(args.m_argv), const_cast(envp)); + } + // ...unless exec fails. In which case we definitely need to end the child here. ExitChildAbnormally(eExecFailed); } -- cgit v1.2.3