13
0

Prefer vfork() over system() when opening an URI

see also https://github.com/surge-synthesizer/surge/issues/657
This commit is contained in:
Robin Gareus 2019-02-26 03:47:36 +01:00
parent b8a6f7b052
commit 6920e5d653
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -34,8 +34,11 @@
#endif
#ifdef PLATFORM_WINDOWS
#include <windows.h>
#include <shellapi.h>
# include <windows.h>
# include <shellapi.h>
#else
# include <sys/types.h>
# include <unistd.h>
#endif
bool
@ -66,13 +69,20 @@ PBD::open_uri (const char* uri)
while (s.find("\"") != std::string::npos)
s.replace(s.find("\\"), 1, "\\\"");
#ifdef NO_VFORK
std::string command = "xdg-open ";
command += '"' + s + '"';
command += " &";
(void) system (command.c_str());
return true;
#else
if (::vfork () == 0) {
::execlp ("xdg-open", "xdg-open", s.c_str(), (char*)NULL);
exit (0);
}
#endif
#endif /* not PLATFORM_WINDOWS and not __APPLE__ */
return true;
}
bool