config file is now ~/.config/RsyncUI.conf
This commit is contained in:
@@ -5,6 +5,10 @@ using namespace std;
|
||||
#define READ 0
|
||||
#define WRITE 1
|
||||
|
||||
//Take a string and explode it in array
|
||||
// s => string to explode
|
||||
// c => character separator
|
||||
// n => number of results in array, the last is the rest of string to end
|
||||
const vector<string> explode(const string& s, const char& c, int n = 0)
|
||||
{
|
||||
string buff;
|
||||
@@ -37,7 +41,9 @@ const vector<string> explode(const string& s, const char& c, int n = 0)
|
||||
return v;
|
||||
}
|
||||
|
||||
FILE * popen2(char * const argv, string type, int & pid)
|
||||
// open a pipe, fork and return pid of child
|
||||
// argv => array of string with command in first and parameters following
|
||||
FILE * popen2(array<string,8> argv, string type, int & pid)
|
||||
{
|
||||
pid_t child_pid;
|
||||
int fd[2];
|
||||
@@ -51,6 +57,7 @@ FILE * popen2(char * const argv, string type, int & pid)
|
||||
NULL,
|
||||
"RsyncUI",
|
||||
message);
|
||||
exit(-1);
|
||||
}else
|
||||
{
|
||||
if((child_pid = fork()) == -1)
|
||||
@@ -74,11 +81,7 @@ FILE * popen2(char * const argv, string type, int & pid)
|
||||
}
|
||||
|
||||
setpgid(child_pid, child_pid); //Needed so negative PIDs can kill children of /bin/sh
|
||||
//if (execlp(argv[0].c_str(), argv[0].c_str(), argv[1].c_str(), argv[2].c_str(), argv[3].c_str(), argv[4].c_str(), argv[5].c_str(), NULL ) == -1)
|
||||
if (execvp(command.c_str(), &argv))
|
||||
{
|
||||
perror("execl error => ");
|
||||
}
|
||||
if (execlp(argv[0].c_str(), argv[0].c_str(), argv[1].c_str(), argv[2].c_str(), argv[3].c_str(), argv[4].c_str(), argv[5].c_str(), NULL ) == -1)
|
||||
exit (0);
|
||||
}
|
||||
else
|
||||
@@ -103,6 +106,10 @@ FILE * popen2(char * const argv, string type, int & pid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// close pipe open by popen2 while pid is finished
|
||||
// fp => file pointer
|
||||
// pid => pid of the processus open bu popen2
|
||||
|
||||
int pclose2(FILE * fp, pid_t pid)
|
||||
{
|
||||
int stat;
|
||||
|
||||
Reference in New Issue
Block a user