[Lldb-commits] [lldb] [lldb] Have lldb-server assign ports to children in platform mode (PR #88845)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 18 01:52:04 PDT 2024


================
@@ -301,13 +294,35 @@ int main_platform(int argc, char *argv[]) {
       exit(socket_error);
     }
     printf("Connection established.\n");
+
     if (g_server) {
       // Collect child zombie processes.
 #if !defined(_WIN32)
-      while (waitpid(-1, nullptr, WNOHANG) > 0)
-        ;
+      ::pid_t waitResult;
+      while ((waitResult = waitpid(-1, nullptr, WNOHANG)) > 0) {
+        // waitResult is the child pid
+        gdbserver_portmap.FreePortForProcess(waitResult);
+      }
 #endif
-      if (fork()) {
+      // TODO: Clean up portmap for Windows when children die
----------------
DavidSpickett wrote:

Please open an issue describing the problem in a bit more detail so we have some context if/when we get around to fixing it. Include an example of when this missing code would be a problem, doesn't have to be super detailed. Then add a link to that issue in the comment here.

"lldb-server on Windows in platform mode does not reuse ports correctly", something like that.

https://github.com/llvm/llvm-project/pull/88845


More information about the lldb-commits mailing list