I have this code to run a program using execl() and I am getting this error:
Cannot open or parse ' arg 3'.
And, when I remove the argument 3, then I am getting the same error for argument 2, any idea?
I was debuging and apparently the first time is _pid is greather than 0, why is that possible?
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);