进程的消亡及释放资源
This commit is contained in:
41
C13-Linux系统编程/process_basic/myshell.c
Normal file
41
C13-Linux系统编程/process_basic/myshell.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
prompt();
|
||||
|
||||
getline();
|
||||
|
||||
parse();
|
||||
|
||||
if (内部命令)
|
||||
{
|
||||
;
|
||||
}
|
||||
else // 外部命令
|
||||
{
|
||||
fork();
|
||||
if (< 0)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
if (0 ==) // child
|
||||
{
|
||||
execXX;
|
||||
perror();
|
||||
exit(1);
|
||||
}
|
||||
else // parent
|
||||
{
|
||||
wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user