================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to