smallsh's Introduction
Author: Alex Wilson Date: October 27 2021 Description: The following program is a shell created using C. The shell has the following fearures... 1. Provide a prompt for running commands 2. Handle blank lines and comments, which are lines beginning with the # character 3. Provide expansion for the variable $$ 4. Execute 3 commands exit, cd, and status via code built into the shell 5. Execute other commands by creating new processes using a function from the exec family of functions 6. Support input and output redirection 7. Support running commands in foreground and background processes 8. Implement custom handlers for 2 signals, SIGINT and SIGTSTP Compile the program as follows: Launch terminal cd into directory containing main.c file. Run command in terminal: gcc --std=gnu99 -o smallsh main.c Run command in terminal: ./smallsh Example. $ smallsh : ls junk smallsh smallsh.c : ls > junk : status exit value 0 : cat junk junk smallsh smallsh.c : wc < junk > junk2 : wc < junk 3 3 23 : test -f badfile : status exit value 1 : wc < badfile cannot open badfile for input : status exit value 1 : badfile badfile: no such file or directory : sleep 5 ^Cterminated by signal 2 : status & terminated by signal 2 : sleep 15 & background pid is 4923 : ps PID TTY TIME CMD 4923 pts/0 00:00:00 sleep 4564 pts/0 00:00:03 bash 4867 pts/0 00:01:32 smallsh 4927 pts/0 00:00:00 ps : : # that was a blank command line, this is a comment line : background pid 4923 is done: exit value 0 : # the background sleep finally finished : sleep 30 & background pid is 4941 : kill -15 4941 background pid 4941 is done: terminated by signal 15 : pwd /nfs/stak/users/chaudhrn/CS344/prog3 : cd : pwd /nfs/stak/users/chaudhrn : cd CS344 : pwd /nfs/stak/users/chaudhrn/CS344 : echo 4867 4867 : echo $$ 4867 : ^C^Z Entering foreground-only mode (& is now ignored) : date Mon Jan 2 11:24:33 PST 2017 : sleep 5 & : date Mon Jan 2 11:24:38 PST 2017 : ^Z Exiting foreground-only mode : date Mon Jan 2 11:24:39 PST 2017 : sleep 5 & background pid is 4963 : date Mon Jan 2 11:24:39 PST 2017 : exit $
smallsh'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.