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

  Design and implement a class contains instance data

Design and implement a class called sphere that contains instance data that represents the sphere's diameter. Define the Sphere constructor to accept and initialize the diameter.

  Calculator to do the suitable matrix exponentiation

Every company makes particular restrictions for passwords, but employees of ABC have particularly strange restrictions. Their passwords may only consist of the lowercase letters

  Write and debug a mips program

Write and debug a MIPS program that performs the given operations - Display one of the following statements depending on if a>b, or a=b or a

  Design a class named rectangle to represent a rectangle

(The Rectangle class ) Following the example of the Circle, design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and height that specify the width and height of the rectangle. The defa..

  Program to input the assignment number

The program must prompt teacher to input the assignment number. Score for student for that assignment will be displayed.

  Create and write payroll program to prompt user for input

Create and write a payroll program that will prompt the user to enter employee's hourly pay rate and the number of hours worked.

  Implement the factorial function in the io monad

Use imperative-style programming to implement the factorial function in the IO monad. In other words, create and initialize variables (references) using newIORef, modify their values using a while loop with ,readIORef and writeIORef, then have th..

  Framework of the program

Write a program to read in up to 100 positive real values from a data file that everyone will name "p4data.dat" , output them in ascending order , calculate and print the average , the median , the variance , and the standard deviation . The..

  Write unix shell scripts using dos commands

Assume you are an experienced DOS programmer and you want to write UNIX shell scripts using DOS commands. Use the alias command so you can type the follow DOS commands and perform UNIX functions

  Electro-magnetic force in newtons

The topic of this assignment was chosen so that you won't allow mathematical equations and scientific notation to intimidate you. No knowledge is required to complete the assignment beyond knowing how to perform mathematical operations within a fo..

  Design and run a program that takes a numerical score

Design and run a program that takes a numerical score and outputs a letter grade. Precise numeral scores and letter grades are listed show.

  Write program to accept long integer number

Write down the program which contains function calories() which is to accept long integer number total and address of integer variables pizza, chips apples and mustard.

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