Your solution for lab #4 will be to create a C program which will accept a number of fixed verb names of your choosing. These will be replacements for variations of normal bash commands. Your program is to recognize the verb requested and create a process to run the equivalent bash command. To create the process you MUST use the fork() function and have the parent process wait() for it to complete. Within the child process you MUST use one of the exec??() family of system calls to execute the required bash verb with your selected parameters. You are not allowed to call aliases or functions defined in your .bashrc (ask me why!). As an example, in my version I have created a verb called "jobtree". When I run my code and type in "jobtree" at the prompt, it will produce the equivalent to the shell command: ps -o user:32,pid,stime,tty,cmd -U jacques --forest When I run jobtree in my shell, the C code will run the bash ps command followed by 5 parameters: "-o", " user:32,pid,stime,tty,cmd", "-U", "jacques", "--forest". I strongly suggest that you get your commands working/tested in bash before you port them into your shell. It will help with debugging issues when things don't work later on. Don't forget to add in an extra command to exit your shell and return to the bash shell. As an example I would add an extra verb like "logout" which would "exit" my C code and return to the original bash process. Of course, logout shouldn't trigger a fork() as this would just create an extra process and not just exit. Ensure that you wait() for every child created by fork() or you will be creating zombie processes. Which, I will have to clean up. They waste system resources so, be vigilant. Do a "ps -ef | grep -e $USER" before you log out and make sure you aren't leaving any zombies behind.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

Your solution for lab #4 will be to create a C program which will accept a number of fixed verb
names of your choosing. These will be replacements for variations of normal bash commands.
Your program is to recognize the verb requested and create a process to run the equivalent bash
command. To create the process you MUST use the fork() function and have the parent process
wait() for it to complete.
Within the child process you MUST use one of the exec??() family of system calls to execute the
required bash verb with your selected parameters. You are not allowed to call aliases or functions
defined in your .bashrc (ask me why!).
As an example, in my version I have created a verb called "jobtree". When I run my code and
type in "jobtree" at the prompt, it will produce the equivalent to the shell command:
ps -o user:32,pid,stime,tty,cmd -U jacques --forest
When I run jobtree in my shell, the C code will run the bash ps command followed by 5
parameters: "-o", " user:32,pid,stime,tty,cmd", "-U", "jacques", "--forest".
I strongly suggest that you get your commands working/tested in bash before you port them into
your shell. It will help with debugging issues when things don't work later on.
Don't forget to add in an extra command to exit your shell and return to the bash shell. As an
example I would add an extra verb like "logout" which would "exit" my C code and return to the
original bash process. Of course, logout shouldn't trigger a fork() as this would just create an
extra process and not just exit.
Ensure that you wait() for every child created by fork() or you will be creating zombie processes.
Which, I will have to clean up. They waste system resources so, be vigilant. Do a "ps -ef | grep -e
$USER" before you log out and make sure you aren't leaving any zombies behind. 

Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education