int main() { // declare our strings for the two parts of input char* cmd= NULL; char* args[ARG_SIZE]= {NULL}; int i= 0; while(TRUE) { // print the prompt printf("# "); if (getUserCommand(&cmd, &args) != 0) { if (strcmp(cmd, "quit") == 0) { free(cmd); for (i= 0; i< ARG_SIZE; i++) free(args[i]); exit(0); } else if (strcmp(cmd, "run") == 0) { if (runRun(args) == 0) printf("error: process not run\n"); } else if (strcmp(cmd, "background") == 0) { pid_t pid; pid= runBackground(args); if (pid > 0) printf("process backgrounded, id is: %jd\n",(intmax_t) pid); else printf("error: process not backgrounded\n"); } else if (strcmp(cmd, "murder") == 0) { runMurder(args); } else if (strcmp(cmd, "for") == 0) { runFor(args); } else { printf("no such command: %s\n", cmd); } } free(cmd); for (i= 0; i< ARG_SIZE; i++) free(args[i]); } }
//----------------------------------------------------------------------------- // 描述: 开始运行服务器 // 备注: 由 iseApp().run() 调用 //----------------------------------------------------------------------------- void IseMainServer::run() { runBackground(); }