Document Preview:
A simple shell (command interpreter) #define TRUE 1! /* declare cmd, params, envp, stat, prompt, readcmd */! ! while (TRUE) { ! !!!/* repeat forever */! !prompt(); ! !!!!/* display prompt */ !readcmd(cmd, params); /* read input from terminal*/! !if (fork() != 0) {! !/* fork child process */! ! !/* parent code */! ! !waitpid(-1, &stat, 0); ! !/* wait for child */! !} else {! ! !/* child code */! ! !execve(cmd, params, envp);!/* execute command */! !}! }!
Attachments:
No comments:
Post a Comment