-
The internal shell command "exit" which terminates the shell
- Concepts: shell commands, exiting the shell.
- System calls:
exit()
-
A command with no arguments
- Example: ls …etc
- Details: The shell must block until the command completes and, if the return code is abnormal, print out a message to that effect.
- Concepts: Forking a child process, waiting for it to complete and synchronous execution.
- System calls:
fork()
,execvp()
,exit()
,wait()
-
A command with arguments
- Example: ls –l, cp source destination, rm filename.
- Details: Argument 0 is the name of the command.
- Concepts: Command-line parameters
-
A command, with or without arguments, executed in the background using &.
- Example: firefox &
- Details: In this case, The shell must execute the command and return immediately, not blocking until the command finishes.
- Concepts: Background execution, signals, signal handlers, processes and asynchronous execution.
Notice how Firefox, Calculator and Gedit are child processes to the SimpleShell process
- command shell should take the user command and its parameter(s), i.e., “ls” and “–l” in this example, and convert them into C strings. (Recall that a C string terminates with a null string, i.e., \0.)
- The command shell should create a child process via
fork()
. - The child process passes the C strings—the command and parameter(s)—to
execvp()
. - The parent process, i.e., the command shell, should wait, via
wait()
, for the child process to finish. - The command shell gets the next command and repeats the above steps. The command shell terminates itself when the user types exit.
In case a user wants to execute the command in background (i.e. as a background process), he/she writes & at the end of the command. For example, a user command can be:
Shell > firefox &
unix-shell's Introduction
unix-shell's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.