实现子shell Unix C

时间:2015-04-08 19:20:26

标签: c unix subshell

我试图在C中实现子shell。我已经有了一个普通的shell,看起来像这样:

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);
}

我试图弄清楚子shell是如何工作的,以及它与上面代码的区别。

提前致谢。

0 个答案:

没有答案