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

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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