diff --git a/kernel/thor/generic/gdbserver.cpp b/kernel/thor/generic/gdbserver.cpp index 96ab60b60..03065c75a 100644 --- a/kernel/thor/generic/gdbserver.cpp +++ b/kernel/thor/generic/gdbserver.cpp @@ -440,8 +440,13 @@ coroutine> GdbServer::handleRequest_() { } // anonymous namespace +static bool launched = false; + void launchGdbServer(smarter::shared_ptr thread, frg::string_view path, smarter::shared_ptr wq) { + if(launched) + return; + launched = true; auto channel = solicitIoChannel("kernel-gdbserver"); if(!channel) { infoLogger() << "thor: No I/O channel available for gdbserver" << frg::endlog; diff --git a/posix/subsystem/src/gdbserver.cpp b/posix/subsystem/src/gdbserver.cpp index 58c81f141..877590531 100644 --- a/posix/subsystem/src/gdbserver.cpp +++ b/posix/subsystem/src/gdbserver.cpp @@ -515,20 +515,20 @@ async::result> GdbServer::handleRequest_() { static bool launched = false; void launchGdbServer(Process *process) { - if(!launched) { - launched = true; - async::detach([] (Process *process) -> async::result { - std::cout << "posix: Starting GDB server" << std::endl; - - auto root = rootPath(); - auto fileOrError = co_await open(root, root, "dev/ttyS0", process); - if(!fileOrError) { - std::cout << "posix, gdbserver: Could not open /dev/ttyS0" << std::endl; - co_return; - } + if(launched) + return; + launched = true; + async::detach([] (Process *process) -> async::result { + std::cout << "posix: Starting GDB server" << std::endl; + + auto root = rootPath(); + auto fileOrError = co_await open(root, root, "dev/ttyS0", process); + if(!fileOrError) { + std::cout << "posix, gdbserver: Could not open /dev/ttyS0" << std::endl; + co_return; + } - GdbServer server{process, fileOrError.value()}; - co_await server.run(); - }(process)); - } + GdbServer server{process, fileOrError.value()}; + co_await server.run(); + }(process)); }