diff --git a/src/process_unix.cpp b/src/process_unix.cpp index 7213621..ecb8805 100644 --- a/src/process_unix.cpp +++ b/src/process_unix.cpp @@ -68,8 +68,7 @@ Process::id_type Process::open(const std::string &command, const std::string &pa else execl("/bin/sh", "sh", "-c", command.c_str(), NULL); - perror("execl"); - exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); } if(stdin_fd) close(stdin_p[0]); diff --git a/src/process_win.cpp b/src/process_win.cpp index 7bf8242..2fcaa6c 100644 --- a/src/process_win.cpp +++ b/src/process_win.cpp @@ -1,6 +1,7 @@ #include "process.hpp" #include #include "TlHelp32.h" +#include #include //TODO: remove using namespace std; //TODO: remove @@ -96,19 +97,13 @@ Process::id_type Process::open(const std::string &command, const std::string &pa #ifdef MSYS_PROCESS_USE_SH size_t pos=0; std::string sh_command=command; - while((pos=sh_command.find('\"', pos))!=std::string::npos) { - if(pos>0 && sh_command[pos-1]!='\\') { - sh_command.replace(pos, 1, "\\\""); - pos++; - } - pos++; + while((pos=sh_command.find('\\', pos))!=std::string::npos) { + sh_command.replace(pos, 1, "\\\\\\\\"); + pos+=4; } pos=0; - while((pos=sh_command.find('\\', pos))!=std::string::npos) { - if((pos+1)==sh_command.size() || sh_command[pos+1]!='\"') { - sh_command.replace(pos, 1, "\\\\\\"); - pos++; - } + while((pos=sh_command.find('\"', pos))!=std::string::npos) { + sh_command.replace(pos, 1, "\\\""); pos+=2; } sh_command.insert(0, "sh -c \"");