Pls can some one help to debug this command interpreter. Can someone help, it complain during compilation.
int main(int argc, char *argv[])
{
int status;
int pid;
char *prog_arv[4];
/* Build argument list */
prog_argv[0] = "/usr/local/bin/ls";
prog_argv[1] = "-l";
prog_argv[2] = "/";
prog_argv[3] = NULL;
/*
* Create a process space for the ls
*/
if ((pid=fork()) < 0)
{
perror ("Fork failed");
exit(errno);
}
if (!pid)
{
/* This is the child, so execute the ls */
execvp (prog_argv[0], prog_argv);
}
if (pid)
{
/*
* We're in the parent; let's wait for the child to finish
*/
waitpid (pid, NULL, 0);
}
}
int status;
int pid;
char *prog_arv[4];
/* Build argument list */
prog_argv[0] = "/usr/local/bin/ls";
prog_argv[1] = "-l";
prog_argv[2] = "/";
prog_argv[3] = NULL;
/*
* Create a process space for the ls
*/
if ((pid=fork()) < 0)
{
perror ("Fork failed");
exit(errno);
}
if (!pid)
{
/* This is the child, so execute the ls */
execvp (prog_argv[0], prog_argv);
}
if (pid)
{
/*
* We're in the parent; let's wait for the child to finish
*/
waitpid (pid, NULL, 0);
}
}