[lldb] Fix flakyness in TestProcessList

If the test is too fast it can read the process list before the forked
child process actually manages to exec the process with the right
arguments.

Use our file-based synchronization primitives to ensure the child is
up-and-running before we fetch the process list.

GitOrigin-RevId: b53641cb72acae8973a16c4f5567885bd3fe85c0
diff --git a/test/API/commands/platform/process/list/TestProcessList.py b/test/API/commands/platform/process/list/TestProcessList.py
index 5daf5dc..683b62e 100644
--- a/test/API/commands/platform/process/list/TestProcessList.py
+++ b/test/API/commands/platform/process/list/TestProcessList.py
@@ -23,8 +23,10 @@
         exe = self.getBuildArtifact("TestProcess")
 
         # Spawn a new process
-        popen = self.spawnSubprocess(exe, args=["arg1", "--arg2", "arg3"])
+        sync_file = lldbutil.append_to_process_working_directory(self,
+                "ready.txt")
+        popen = self.spawnSubprocess(exe, args=[sync_file, "arg1", "--arg2", "arg3"])
+        lldbutil.wait_for_file_on_target(self, sync_file)
 
-        substrs = [str(popen.pid), "TestProcess arg1 --arg2 arg3"]
-
+        substrs = [str(popen.pid), "TestProcess", "arg1 --arg2 arg3"]
         self.expect("platform process list -v", substrs=substrs)
diff --git a/test/API/commands/platform/process/list/main.cpp b/test/API/commands/platform/process/list/main.cpp
index da43e60..955f6e4 100644
--- a/test/API/commands/platform/process/list/main.cpp
+++ b/test/API/commands/platform/process/list/main.cpp
@@ -1,9 +1,9 @@
-#include <stdio.h>
-
 #include <chrono>
+#include <fstream>
 #include <thread>
 
 int main(int argc, char const *argv[]) {
+  std::ofstream(argv[1]).close();
   std::this_thread::sleep_for(std::chrono::seconds(30));
   return 0;
 }