c编写shell

基本框架

1
2
3
4
5
6
7
8
9
10
11
while(TRUE) {                  
  type_prompt();               /* display prompt on the screen */
  read_command(command,parameters);    /* read input from terminal */
  if(fork()!=0) {              /* fork off child process */
    /* Parent code */
    waitpid(-1,&status,0);        /* wait for child to exit */
  } else {
    /* Child code */
    execve(command,parameters,0);    /* execute command */
  }
}