GooMooPunch
Programmer
Hello,
I have a shell program with a function that handles external unix calls, but I can't figure out how to make it so I can use an exec call because the amount of arguments being sent to the function is different for different external commands...
int exCmdhandler(char* cmd, char* args[]){
pid_t child = fork();
if(child == 0)
if(execlp(cmd, cmd, NULL) == -1) {
printf("Error: %s\n", srerror(errno));
return 1;
}
else if(child != -1) {
int status;
waitpid(child, &status, 0);
}
return 0;
}
-----------
I've tried using execvp and passing the args array to it, but it gives me a Bad Address error...
I have a shell program with a function that handles external unix calls, but I can't figure out how to make it so I can use an exec call because the amount of arguments being sent to the function is different for different external commands...
int exCmdhandler(char* cmd, char* args[]){
pid_t child = fork();
if(child == 0)
if(execlp(cmd, cmd, NULL) == -1) {
printf("Error: %s\n", srerror(errno));
return 1;
}
else if(child != -1) {
int status;
waitpid(child, &status, 0);
}
return 0;
}
-----------
I've tried using execvp and passing the args array to it, but it gives me a Bad Address error...