debug
This commit is contained in:
@@ -1,11 +1,4 @@
|
||||
#include "mainwindow.h"
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <pstreams/pstream.h>
|
||||
#include <QMessageBox>
|
||||
#include <ctype.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -44,11 +37,12 @@ const vector<string> explode(const string& s, const char& c, int n = 0)
|
||||
return v;
|
||||
}
|
||||
|
||||
FILE * popen2(array<string, 7> argv, string type, int & pid)
|
||||
FILE * popen2(char * const argv, string type, int & pid)
|
||||
{
|
||||
pid_t child_pid;
|
||||
int fd[2];
|
||||
QString message;
|
||||
string command;
|
||||
|
||||
if (pipe(fd) == -1)
|
||||
{
|
||||
@@ -80,7 +74,8 @@ FILE * popen2(array<string, 7> argv, string type, int & pid)
|
||||
}
|
||||
|
||||
setpgid(child_pid, child_pid); //Needed so negative PIDs can kill children of /bin/sh
|
||||
if (execl(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 (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 => ");
|
||||
}
|
||||
@@ -98,14 +93,11 @@ FILE * popen2(array<string, 7> argv, string type, int & pid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pid = child_pid;
|
||||
|
||||
if (type == "r")
|
||||
{
|
||||
return fdopen(fd[READ], "r");
|
||||
}
|
||||
|
||||
return fdopen(fd[WRITE], "w");
|
||||
}
|
||||
return 0;
|
||||
@@ -124,7 +116,6 @@ int pclose2(FILE * fp, pid_t pid)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user