From 6c9fc2ac3805c3f5dc71f454cec72e434bec1763 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 1 Jan 2013 16:50:50 +0300 Subject: Fix some issues in process creation. --- src/utils/process.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') 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 +#include #include #include @@ -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(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 -- cgit v1.2.3-60-g2f50