N
noelloen
hi,
I have the following code,
int ret;
char ** vector;
//vector[0] = "ls" vector[1] ="-al"
.....
//fork a child
......
ret= execvp(*temp, temp);
if( ret == -1)
perror(*vector);
.......
which works fine. and the child display the "ls -al"
But when I use the case "ls" alone, and "ls -a -l" it does not work,
and complains:
ls: Bad address
or
sometime gives
wrong args given
------- Failed Examples--------
the temp[i+1] %7182
parent: 6129 childtemp_pid 436
kill: %7182: no such job
/usr/bin/kill[8]: : Arguments must be %job or process ids
the temp[0] ps
the temp[i+1] -u
the temp[i+1] root
parent: 3635 childtemp_pid 3639
ps: Bad address
the temp[0] ls
the temp[i+1] -a
the temp[i+1] -l
parent: 3659 childtemp_pid 3660
ls: Bad address
only the following case works
ls -al
....runs and gives the output....
Since execvp does not require a path, I wonder what went wrong that it
does not see the bin executables, and if so why there is one case work?
Thank you very much.
I have the following code,
int ret;
char ** vector;
//vector[0] = "ls" vector[1] ="-al"
.....
//fork a child
......
ret= execvp(*temp, temp);
if( ret == -1)
perror(*vector);
.......
which works fine. and the child display the "ls -al"
But when I use the case "ls" alone, and "ls -a -l" it does not work,
and complains:
ls: Bad address
or
sometime gives
wrong args given
------- Failed Examples--------
the temp[0] killkill %7182 //my input as child process
the temp[i+1] %7182
parent: 6129 childtemp_pid 436
kill: %7182: no such job
/usr/bin/kill[8]: : Arguments must be %job or process ids
This is default caseps -u root //my input as child process
the temp[0] ps
the temp[i+1] -u
the temp[i+1] root
parent: 3635 childtemp_pid 3639
ps: Bad address
This is default casels -a -l
the temp[0] ls
the temp[i+1] -a
the temp[i+1] -l
parent: 3659 childtemp_pid 3660
ls: Bad address
only the following case works
ls -al
....runs and gives the output....
Since execvp does not require a path, I wonder what went wrong that it
does not see the bin executables, and if so why there is one case work?
Thank you very much.