summaryrefslogtreecommitdiff
path: root/drivers/unix/os_unix.cpp
diff options
context:
space:
mode:
authorhurikhan <m4r10.5ch14ck@gmail.com>2015-02-12 15:58:29 +0100
committerhurikhan <m4r10.5ch14ck@gmail.com>2015-02-12 15:58:29 +0100
commita13e180052d2e17275498a2fa78185cc299ace11 (patch)
tree6f9051d0b3d2444ac09c1bbf78f9e395af1782e9 /drivers/unix/os_unix.cpp
parentdf7d26ff5b89ce9852813abd370d1357aab1501b (diff)
parentb3a6cc097d5bc60ee6e7ba30b177bed3a8aadc71 (diff)
Merge remote-tracking branch 'upstream/master' into x11-window-management
Diffstat (limited to 'drivers/unix/os_unix.cpp')
-rw-r--r--drivers/unix/os_unix.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 2de975e5d1..d51a7c74e8 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -44,7 +44,9 @@
#include "stream_peer_tcp_posix.h"
#include "packet_peer_udp_posix.h"
-
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#endif
#include <stdarg.h>
#include <sys/time.h>
#include <sys/wait.h>
@@ -305,7 +307,17 @@ Error OS_Unix::execute(const String& p_path, const List<String>& p_arguments,boo
args.push_back((char*)cs[i].get_data());// shitty C cast
args.push_back(0);
+#ifdef __FreeBSD__
+ if(p_path.find("/")) {
+ // exec name contains path so use it
+ execv(p_path.utf8().get_data(),&args[0]);
+ }else{
+ // use program name and search through PATH to find it
+ execvp(getprogname(),&args[0]);
+ }
+#else
execv(p_path.utf8().get_data(),&args[0]);
+#endif
// still alive? something failed..
fprintf(stderr,"**ERROR** OS_Unix::execute - Could not create child process while executing: %s\n",p_path.utf8().get_data());
abort();
@@ -421,6 +433,12 @@ String OS_Unix::get_executable_path() const {
return OS::get_executable_path();
}
return b;
+#elif defined(__FreeBSD__)
+ char resolved_path[MAXPATHLEN];
+
+ realpath(OS::get_executable_path().utf8().get_data(), resolved_path);
+
+ return String(resolved_path);
#else
ERR_PRINT("Warning, don't know how to obtain executable path on this OS! Please override this function properly.");
return OS::get_executable_path();