diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-01-01 16:50:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-01-01 16:51:17 +0300 |
commit | 6c9fc2ac3805c3f5dc71f454cec72e434bec1763 (patch) | |
tree | 480f8e4b1e29471b7d64e8f6cb4e204de8a9d7cc /src | |
parent | cdb069409c514a1cec196c2e90ec2f97a5b6753f (diff) | |
download | manaverse-6c9fc2ac3805c3f5dc71f454cec72e434bec1763.tar.gz manaverse-6c9fc2ac3805c3f5dc71f454cec72e434bec1763.tar.bz2 manaverse-6c9fc2ac3805c3f5dc71f454cec72e434bec1763.tar.xz manaverse-6c9fc2ac3805c3f5dc71f454cec72e434bec1763.zip |
Fix some issues in process creation.
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/process.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/utils/process.cpp b/src/utils/process.cpp index 56f26b2fa..a4c4d3143 100644 --- a/src/utils/process.cpp +++ b/src/utils/process.cpp @@ -100,6 +100,7 @@ bool execFile(std::string pathName, std::string name A_UNUSED, #elif defined __linux__ || defined __linux || defined __APPLE__ #include <sys/types.h> +#include <sys/stat.h> #include <sys/wait.h> #include <signal.h> @@ -182,6 +183,11 @@ int execFileWait(std::string pathName, std::string name, bool execFile(std::string pathName, std::string name, std::string arg1, std::string arg2) { + struct stat statbuf; + // file not exists + if (stat(pathName.c_str(), &statbuf)) + return false; + pid_t pid; if ((pid = fork()) == -1) { // fork error @@ -199,6 +205,7 @@ bool execFile(std::string pathName, std::string name, execl(pathName.c_str(), name.c_str(), arg1.c_str(), arg2.c_str(), static_cast<char *>(nullptr)); } + _exit(-1); return false; } return true; @@ -230,12 +237,12 @@ bool openBrowser(std::string url) #elif defined __linux__ || defined __linux bool openBrowser(std::string url) { - return execFile("/usr/bin/xdg-open", "/usr/bin/xdg-open", url, "") == 0; + return execFile("/usr/bin/xdg-open", "/usr/bin/xdg-open", url, ""); } #elif defined __APPLE__ bool openBrowser(std::string url) { - return execFile("/usr/bin/open", "/usr/bin/open", url, "") == 0; + return execFile("/usr/bin/open", "/usr/bin/open", url, ""); } #else |