Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write in C++ or in C. Please do not copy/paste the other solution as it has nothing related to shell scripting Your assignment is
Please write in C++ or in C. Please do not copy/paste the other solution as it has nothing related to shell scripting
Your assignment is to build a program tish that will implement the following shell services:
- Run programs in foreground and background;
- List all processes that currently run in the background.
- Kill a process running in the background.
The precise requirements are as following:
- Your shell should give a user tish>> as a prompt;
- There are two types of commands that tish should understand:
- External commands: the command name is, in fact, the name of an executable file. When an external command is requested this means that the corresponding executable file should be run.
- Internal commands: commands that are built-in in the tish shell. For example, the bye command does not correspond to any executable file. Instead, it causes tish to execute the exit system call. Below we specify which internal commands you are required to implement.
- Execution mode for external commands:
- Foreground: a command is given in the following form tish>> . In this mode tish does not return the prompt until the executable file that corresponds to the command finishes.
- Background: a command is given in the same format as in the foreground mode, but the last parameter in the parameter list should be &. for example: tish>> emacs &
- Example of running external commands:
- tish>> emacs my_file.
- List of Internal commands you are required to implement:
- bye : terminate tish. All background processes should be terminated. (Note that the real shell does not do this).
- jobs : list of all background jobs in the following format: , in the order of creation.
kill :terminate the process corresponding to the specified pid by sending SIGTERM signal.
System Calls and Functions List
- fork();
- execvp();
- wait();
- signal();
- kill();
- exit();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started