summaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-12-11 11:47:08 +0000
committeryexo <yexo@openttd.org>2011-12-11 11:47:08 +0000
commitb4fdba2fb3afcb80e419c048504a118ec8376c09 (patch)
tree036ce622e3bfe2b3176bfe3eecab55f9a943051b /src/os/unix
parent0143f00d6fbe33f1de293c4149bf8ad05bac4d8a (diff)
downloadopenttd-b4fdba2fb3afcb80e419c048504a118ec8376c09.tar.xz
(svn r23490) -Add [FS#2750]: OpenBrowser function to open a browser on major OSes
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/unix.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp
index 700a9050c..7cd9709f8 100644
--- a/src/os/unix/unix.cpp
+++ b/src/os/unix/unix.cpp
@@ -14,6 +14,7 @@
#include "../../openttd.h"
#include "../../crashlog.h"
#include "../../core/random_func.hpp"
+#include "../../debug.h"
#include <dirent.h>
@@ -348,4 +349,18 @@ uint GetCPUCoreCount()
return count;
}
+
+void OSOpenBrowser(const char *url)
+{
+ pid_t child_pid = fork();
+ if (child_pid != 0) return;
+
+ const char *args[3];
+ args[0] = "/usr/bin/xdg-open";
+ args[1] = url;
+ args[2] = NULL;
+ execv(args[0], const_cast<char * const *>(args));
+ DEBUG(misc, 0, "Failed to open url: %s", url);
+ exit(0);
+}
#endif