0

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);
user1681210
  • 85
  • 2
  • 10

1 Answers1

1

It sounds more like whatever you're executing can't open or parse your arguments.

Michael Krelin - hacker
  • 138,757
  • 24
  • 193
  • 173
  • why can be that possible?, when I executed directly it is working fine. i am trying to run gnugo program with the arguments --color black --boardsize 9 .... any idea? – user1681210 Sep 25 '12 at 19:58
  • and your code is basically `execl("/path/to/gnugo","/path/to/gnugo","--color","black","--boardsize","9",NULL);`? If so, then no idea. Otherwise tell me what it looks like. I come to suspect now that you did `"--color black","--boardsize 9",NULL`, could that be? – Michael Krelin - hacker Sep 25 '12 at 20:24