summaryrefslogtreecommitdiff
path: root/src/utils/process.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-01 16:50:50 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-01 16:51:17 +0300
commit6c9fc2ac3805c3f5dc71f454cec72e434bec1763 (patch)
tree480f8e4b1e29471b7d64e8f6cb4e204de8a9d7cc /src/utils/process.cpp
parentcdb069409c514a1cec196c2e90ec2f97a5b6753f (diff)
downloadplus-6c9fc2ac3805c3f5dc71f454cec72e434bec1763.tar.gz
plus-6c9fc2ac3805c3f5dc71f454cec72e434bec1763.tar.bz2
plus-6c9fc2ac3805c3f5dc71f454cec72e434bec1763.tar.xz
plus-6c9fc2ac3805c3f5dc71f454cec72e434bec1763.zip
Fix some issues in process creation.
Diffstat (limited to 'src/utils/process.cpp')
-rw-r--r--src/utils/process.cpp11
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