我正在从 GUI 创建此类的实例on_click()
。它应该fork()
是一系列其他过程。它运行良好,直到最后 GUI 关闭并出现错误:
免费():无效指针:0x000000000209c608
我理解这意味着程序正在尝试访问一个禁止访问的内存位置。我正在使用 QT creator,但似乎无法让调试器正常工作。这是代码:
scriptfilefeed::scriptfilefeed() { }
scriptfilefeed::scriptfilefeed(vector<vector<vector<string> > > & newFeed, double trimParam1, unsigned int trimParam2)
{
const string min = "<TMIN>";
const string max = "<TMAX>";
bla[0] = "6";
bla[1] = "47";
input.clear();
for (int i = 0; i < newFeed.size(); i++)
{
if (i == 1)
{ // then we first need to run trimlowQ to get arguments
}
input.clear();
for (int j = 0; j < newFeed[i].size(); j++)
{
for (int k = 0; k < newFeed[i][j].size(); k++)
{
curstr = newFeed[i][j][k];
input.push_back(curstr.c_str());
if (i == 1 && input.at(j) == min)
{ // const string comp.for trim parameters
input.pop_back(); // remove last element
input.push_back(bla[0]); // insert this instead
}
if (i == 1 && input.at(j) == max)
{
input.pop_back(); // remove last element
input.push_back(bla[1]);
}
cout << newFeed[i][j][k] << endl;
}
}
while (input.size() <= 13)
{
input.push_back(0);
}
cout << "Starting Process: " << input.at(1) << endl;
child = fork();
int ret;
if (child == 0)
{
ret = execl(input.at(0), input.at(1), input.at(2), input.at(3), input.at(4), input.at(5), input.at(6), input.at(7), input.at(8), input.at(9), input.at(10), input.at(11), input.at(12));
printf("failed... ret=%d\n", ret);
perror("this error occured:");
}
bool childEnded = false;
while (childEnded == false)
{
int status;
int result = waitpid(child, &status, WNOHANG);
if (result == 0)
{
// keep going
}
else if (result == -1)
{
// continue
}
else
{
childEnded = true;
cout << "Process Finished" << endl;
}
}
}
}