0

我有这段代码可以使用 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);
4

1 回答 1

1

听起来更像是您正在执行的任何内容都无法打开或解析您的参数。

于 2012-09-25T18:57:22.840 回答