Write a simple shell program

Assignment Help Programming Languages
Reference no: EM13990686

Description

This assignment helps you learn about processes and basic process management in a shell. You are asked to write a simple shell program called minish. This shell must work as follows. You start the shell by typing minish at the prompt. This will give a prompt of your shell as follows:

minish>

From here onwards, you should be able to execute and control any program/command just as you would in a normal shell. For instance

minish> ls

[ OUTPUT OF ls COMMAND SHOWN HERE ]

minish>

Additionally, your shell should be able to do the following:

  1. Execute commands with multiple arguments. For example:
    		minish> Command arg1 arg2 arg3		
  2. Execute commands in either foreground or background mode. In foreground mode, the shell just waits for the command to complete before displaying the shell prompt again (as in the above example). In background mode, a command is executed with an ampersand & suffix. The shell prompt appears immediately after typing a command name (say Command1) and shell becomes ready to accept and execute the next command (say Command2), even as Command1 continues executing in the background. For example:
    		minish> Command1 &
    		minish> Command2
    
    		[OUTPUT OF Command1 AND Command2 MAY INTERLEAVE HERE IN ARBITRARY ORDER]
    		
  3. Maintain multiple processes running in background mode simultaneously. For example:
    		minish> Command1 &
    		minish> Command2 &
    		minish> Command3 &
    		minish> 
    
    		[OUTPUT OF Command1, Command2, AND Command3 MAY INTERLEAVE HERE IN ARBITRARY ORDER]		
  4. Redirect the input of a command from a file. For example:
    		minish> Command < input_file		
    Redirect the output of a command to a file. For example:
    		minish> Command > output_file		
  5. Implement command filters, i.e., redirect the stdout of one command to stdin of another using pipes. For example:
    		minish> ls -l | wc -l		
    		minish> cat somefile | grep somestring | less
    		
    Ideally, your shell should be able to handle any number of filter components.
  6. Terminate a process by pressing [Ctrl-C]. Your shell must not get killed; only the process running inside your shell must terminate.
  7. Temporarily stop a process using [Ctrl-Z]. Your shell must not stop; only the process running inside your shell must stop. Your shell must be able to hold multiple processes in stopped state.
  8. Kill a stopped process or a process in background using the kill command.
  9. Any signal should be delivered to the entire process-group of the immediate child process, not just to the immediate child process. For example, if mysh starts process A and process A forks another process B, then any signal should be delivered to both process A and process B. How will you do this? For this you need to understand the notion of a process group. Check out the man pages forsetsid() and killpg().
  10. Bring a backgrounded process to foreground using the fg directive. The fg directive must be able to bring any stopped/backgrounded process to foreground using the %N argument.
  11. Be able to execute any feasible combinations of the above features.
  12. The exit command should terminate your shell. Take care to avoid orphan processes.
  13. The cd command must actually change the directory of your shell and the pwd command must return the current directory of your shell. Note that normal fork-exec mechanism won't work here. Why?

Reference no: EM13990686

Questions Cloud

Advantages and disadvantages of the electronic health record : Advantages and disadvantages of the electronic health record. Concerns and benefits of the public with adoption of the electronic health record
Problem regarding the unbiased estimator : Show by induction on r that S ≡ 0, then that V ≡ 0. (b) Un is the unbiased estimator of g(Q) with smallest variance. Hint: For an unbiased estimator T with symmetrization W, W = Un by part (a).
Problem unique unbiased estimator : Then K/n is the usual unbiased estimator of p. Show that for n = 2 there is a unique unbiased estimator of p2. For what value(s) of K are its values remarkable?
Explain the audit risk model to the decision makers : How would you explain the audit risk model to the decision makers at AV Imports and Exports? Research risk assessment using your textbook and the Argosy University online library resources and prepare a response. In your response, include the foll..
Write a simple shell program : Execute commands with multiple arguments - You are asked to write a simple shell program called minish.
What''s a good way to memorize the elements in chemistry : What's a good way to memorize the elements in Chemistry? I know it's a dumb question but are there any suggestions for quick memorization? What is recommended?
Usefulness of the resulting estimator : The problem is to estimate e-λ. Let V be an unbiased estimator of e-λ, so that V (k) is defined for k = 1, 2,..., with J,k≥1 e- λλk V (k)/(k!(1 - e -λ)) = e -λ, for all λ > 0. Solve, if possible, for the V (k) and comment on the properties and use..
An oxide of vanadium is 43.99% oxygen by mass : An oxide of vanadium is 43.99% oxygen by mass. What is the empirical formula of this oxide?
Determine the frequency of the motion : At t = 0, a 740g mass at rest on the end of a horizontal spring (k = 115N/m) is struck by a hammer, which gives it an initial speed of 2.82m/s. Determine the period of the motion. Determine the frequency of the motion.

Reviews

Write a Review

Programming Languages Questions & Answers

  The set methods should verify that length and width are

rectangle class create a class rectangle with attributes length and width each of which defaults to 1. provide methods

  Create an application in which a user can enter a phone book

Create an application in which a user can enter a phone book entry, including the following elements

  Allow customers the option of five t-shirt sizes

Allow customers the option of five T-shirt sizes and styles: XXL Short Sleeve, XL Short Sleeve, L Short Sleeve, M Short Sleeve, S Short Sleeve. Assume that each product has a unique price that is displayed when the user cliks a Buy Now button.

  How theory designates team member roles and responsibilities

Explain how participation, leadership, and motivational skills would be demonstrated according to this theory.

  Pseudocode for linear search by using clrs3e style

Write pseudocode for linear search by using CLRS3e style used in, which scans through the sequence, looking for v.

  Presenting football greatest expertise of reviewing

The start of Buy Fifa Coins the one of the most well-known minutes presenting football greatest expertise of reviewing. Before we look into the coordinate it is only reasonable to take a brief look into the gamer considered as one of the best game..

  Write a report document for the hvac controller

write a report document for the HVAC Controller and To use integrated modular programming techniques in developing the project

  Draw diagram shows occupancy of buffer as function of time

A transmitter with rate R bps serves the buffer by sending the bits whenever available. Draw a diagram that shows the occupancy of the buffer as a function of time, for different ranges of values for R.

  Explain calling functions and pass functions by value

I need to create 2 functions which passe their values when they are called in main.

  Create a class that simulates an alarm clock

Store time in hours, minutes, and seconds. Note if time is AM or PM. (Hint: You should have separate private members for the alarm and the clock. Do not forget to have a character variable representing AM or PM.)

  Explain a work place program designed to help participants

Write down four one-sentence goals for program. Each of the four goals shold associate to successful program completion and must promote one specific health behavior.

  Program to input name-weight and price of item

The program must input name and price of item and its weight in pounds and ounces. Then it must determine and display unit price (the price per ounce) of the item.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd