POSIX shell 实现

含有后台运行功能,日后会不定期加入管道功能,历史记录功能 

#include #include #define MAX_LINE 80 void setup(char inputBuffer[], char *args[],int *background) { int length, i, start, ct; ct = 0; length = read(STDIN_FILENO, inputBuffer, MAX_LINE); start = -1; if (length == 0) exit(0); if (length < 0){ perror("error reading the command"); exit(-1); } for (i=0;i\n"); setup(inputBuffer,args,&background); pid_t pid; pid = fork(); if (pid < 0) { fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { execvp(args[0], args); } else if (background == 1) wait(NULL); } }

转载于:https://www.cnblogs.com/seebro/archive/2011/08/29/2476555.html

你可能感兴趣的:(POSIX shell 实现)