From 9e9583412eb88984bc9ce992fa02cdf319510db2 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 28 Sep 2023 13:01:56 -0700 Subject: [PATCH] [wpigui] Make wpi::gui::OpenURL() fork the process first (#5687) execlp() replaces the current process image, which isn't desirable. --- wpigui/src/main/native/cpp/wpigui_openurl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wpigui/src/main/native/cpp/wpigui_openurl.cpp b/wpigui/src/main/native/cpp/wpigui_openurl.cpp index b913cebf0e..f6095670fc 100644 --- a/wpigui/src/main/native/cpp/wpigui_openurl.cpp +++ b/wpigui/src/main/native/cpp/wpigui_openurl.cpp @@ -23,6 +23,10 @@ void wpi::gui::OpenURL(const std::string& url) { #else static constexpr const char* opencmd = "xdg-open"; #endif - execlp(opencmd, opencmd, url.c_str(), static_cast(nullptr)); + // If we forked into the child process, run execlp(), which replaces the + // current process image + if (fork() == 0) { + execlp(opencmd, opencmd, url.c_str(), static_cast(nullptr)); + } #endif }