我有这个代码使用execl()运行程序,我收到此错误:
Cannot open or parse ' arg 3'.
而且,当我删除参数3时,我得到了参数2的相同错误,任何想法?
我正在调试,显然第一次是_pid比0更好,为什么会这样?
int down[2], up[2];
pipe(down); // creates pipe - [0] is for reading, [1] for writing
pipe(up);
pid_t _pid = fork();
if (_pid < 0)
exit(1);
if (_pid == 0)
{
close(down[1]);
close(up[0]);
dup2(down[0], 0);
dup2(up[1], 1);
execl(cmd_line, cmd_line, "arg 1", "arg 2", "arg 3", NULL);
_exit(1);
}
// the rest of this fn is executed by the parent only
close(down[0]);
close(up[1]);
_down = down[1];
_up = up[0];
_reader_thd = new Thread(reader_wrapper, this);
答案 0 :(得分:1)
听起来更像是你正在执行的任何东西无法打开或解析你的论点。