Skip to content

Latest commit

 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Jessi Frenzel | frenzeje@oregonstate.edu

This is the portfolio project for course CS 374 - Operating Systems at Oregon State University.

In this assignment I wrote my own shell in C called smallsh.
smallsh implements a subset of features of well-known shells, such as bash.

Program Capabilities

  • Provides a prompt for running commands
  • Handles blank lines and comments, which are lines beginning with the # character
  • Executes these 3 commands via code built into the shell
    • exit, cd, and status
  • Executes other commands by creating new processes using a function from the exec() family of functions
  • Supports input and output redirection
  • Supports running commands in foreground and background processes
  • Implements custom handlers for 2 signals, SIGINT and SIGTSTP

Learning Objectives Addressed by this Project:

  • How to describe the Linux process API
  • How to write programs using the Linux process API
  • How to explain the concept of signals and their uses
  • How to write programs using the Linux API for signal handling
  • How to explain I/O redirection and write programs that can employ I/O redirection

How to Run

To run this program, first compile it using:

make smallsh

Then run using:

./smallsh

Sample Output:

$ 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/CS374/prog3 : cd : pwd /nfs/stak/users/chaudhrn : cd CS374 : pwd /nfs/stak/users/chaudhrn/CS374 : echo 4867 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 $

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages