Im sure it has something to do with the wait() call, but everything ive tried either leaves me with a zombie or with the exec executing indefinitely.
switch(pid = fork())
{
case -1:perror("fork failed");
exit(1);
case 0:
if(key == "cd")
{
execl("/bin/cd", "cd", data, (char *)0);
}
else{
execl("/bin/sh", key, data, (char *)0);
perror("exec failed");
exit(status);
}
default: waitpid (pid, &status, 0);
printf("Done: \n");
exit(0);
}