I'm trying to implement a subshell in C. I already have a normal shell, which looks like this:
int status;
pid = fork();
if (pid < 0) {
exit(1);
}
else if (pid == 0) {
if (execvp(node->command.program, node->command.argv) < 0) {
exit(1);
}
}
else {
waitpid(pid, &status, 0);
}
I'm trying to figure out how a subshell works, and how it differs from the code above.
Thanks in advance.