Question
Type this in python In this assignment you will implement the RUN functionality of your command interpreter . Your RUN command takes one argument. The
Type this in python
In this assignment you will implement the RUN functionality of your command interpreter.
Your RUN command takes one argument. The executable file specified by the argument should be run and when finished, the prompt displayed. The syntax is:
RUN executable-file
The algorithm for RUN would be as follows.
Define a parent function in which you:
Fork a child process.
Block the parent process to wait till child process ends
If child process is created successfully, call a child function that implements the child process
Define a child function from which you execute the executable program
This will require the following library functions (in Python on UNIX)
os.fork( ) creates a child process and returns the PID of the child process to the parent. Child PID is 0.
subprocess.call(path/executableProgram) executes a program in the current process
os.waitpid(pid,0) causes the parent to block until the child finishes
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