Prefer vfork() over system() when opening an URI
see also https://github.com/surge-synthesizer/surge/issues/657
This commit is contained in:
parent
b8a6f7b052
commit
6920e5d653
@ -36,6 +36,9 @@
|
|||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <shellapi.h>
|
# include <shellapi.h>
|
||||||
|
#else
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -66,13 +69,20 @@ PBD::open_uri (const char* uri)
|
|||||||
while (s.find("\"") != std::string::npos)
|
while (s.find("\"") != std::string::npos)
|
||||||
s.replace(s.find("\\"), 1, "\\\"");
|
s.replace(s.find("\\"), 1, "\\\"");
|
||||||
|
|
||||||
|
#ifdef NO_VFORK
|
||||||
std::string command = "xdg-open ";
|
std::string command = "xdg-open ";
|
||||||
command += '"' + s + '"';
|
command += '"' + s + '"';
|
||||||
command += " &";
|
command += " &";
|
||||||
(void) system (command.c_str());
|
(void) system (command.c_str());
|
||||||
|
#else
|
||||||
return true;
|
if (::vfork () == 0) {
|
||||||
|
::execlp ("xdg-open", "xdg-open", s.c_str(), (char*)NULL);
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* not PLATFORM_WINDOWS and not __APPLE__ */
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
Reference in New Issue
Block a user