Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Will leave like rating :) 1. You will implement the general system process call API in C using fork, wait, and execvp. 2. You will
Will leave like rating :)
1. You will implement the general system process call API in C using fork, wait, and execvp. 2. You will be able to describe how Unix implements general process execution of a child from a parent process. 3. You will write a shell program in C so that you can see how child processes are created and destroyed \& how they interact with parent processes. General Instructions and Hints: -The code for this assignment must be in C. -There is a significant amount of documentation in this assignment that you must read; you are better of starting it sooner rather than later. -Global variables are not allowed and you must use prototypes -Name files exactly as described in the documentation below. -All functions should match the assignment descriptions. Do not add parameters, change names, or return different values. -All output should match exactly what is in this document (including spacing!). If it does not match, it will not pass the autograder. -When part 1 is done, open a terminal and cd to your github repo, wherever you saved it. Do the following: git add . then git commit m then git push. -All work should be done on a machine where you have sudoer permission. -All work should be your own. Part 1, the Process API Background Normally, when you log in, the OS will create a user process that binds to the login port; this causes the user process at that port to execute a shell. A shell (command line interpreter) allows the user to interact with the OS and the OS to respond to the user. The shell is a character-oriented interface that allows users to type characters terminated by Enter (the in char). The OS will respond by sending characters back to the screen. If the OS is using a GUI, the window manager software will take over any shell tasks, and the user can access them by using a screen display with a fixed number of characters and lines. We commonly call this display your terminal, shell, or console, and in Linux, it will output a prompt, which is usually your user@machineName followed by the terminal's current place in the file system and then a $ (see Figure 2). Common commands in Linux use bash, and usually take on the form of command argument1 ... argumentN For example, in chmod u+x > chmod is the command, u+x _is an argument and _filename > is an argument. Not all commands require arguments- for example, you can run is with and without any arguments. After entering a command at the prompt, the shell creates a child process to execute whatever command you provided. The following are the steps that the shell must take to be functional: 1. Print a prompt and wait for input. 2. Get the command line input. 3. Parse the command line input. 4. Find associated files. 5. Pass any parameters from the shell to the OS command function. 6. Execute the command (with applicable parameters). General Directions Name your program systemCaller.c. You will turn in the C code. Failure to do so will result in a 0 on this portion. In this part of the assignment, you will write a function called executeCommand in the C language. We will use the execvp system call to launch processes when possible. However, the exit and cd (change directories) commands are not executed by execvp- they have their own system calls. This program should consist of, at minimum, 4 functions: main, executeCommand, changeDirectories, and parselnput (which is provided to you below). For each function, the name, retum type, parameters, edge cases and exceptions that you must address, and description of functionality are provided. You may implement additional functions as you see fit. In other words, I'm asking you to write a very stripped down shell that uses a very stripped down process API. Generally speaking, the program will execute a shell and loop until the user chooses to exit (you've seen a very basic code example of this in lecture). This shell will be interactive- that is, you will run the program (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