Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Struct's Structures are what was in C prior to C++. They group together fields into a single variable. There are no methods with a struct

Struct's

Structures are what was in C prior to C++. They group together fields into a single variable.

There are no methods with a struct

There are no access types with a struct (private, public, protected) Everything is public - they are just there to allow easy grouping of data.

Accessed the same way an object would be: struct rusage r; cout << r.ru_maxrss;

For your first Homework, you will code a simple program in C++ to read commands from the console and execute them. The mini shell should look for commands in the current path to execute and, if they are present, execute them. If the command is not found an error message stating "command not found" should be sent to cerr or stderr. Rather than just executing commands as typed you will have an alias facility. The alias facility will allow the user to customize commands. For example, if they would prefer dir rather than ls they would type

alias dir ls

And then when they type dir your program will substitute in ls (for the first argument only). The alias facility can also include multiple words or flags and they can be substituted. Another example would be :

alias print lpr -Plj1026

Which would substitute lpr for the first argument followed by -Plj1026 for the second argument. Your shell should fork and execute the command in a separate process. It should then wait for the command to be done and print out the status code for the job along with the resource usages (see wait3 and wait4 calls). Lastly, your shell should keep a list of the commands that have been run (a history) and at the end of the shell session, it should be saved in a file named .minihistory.

In this question, you will NOT be doing wildcard substitution, redirection, piping, or actually use the history

You are NOT allowed to

use the system call.

Must be fork/exec/wait

No, you can't alias an alias - if you said

alias p print

It shouldn't check on print being an alias and substitute in the lpr -Plj1026

command

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

b. Does senior management trust the team?

Answered: 1 week ago

Question

How will the members be held accountable?

Answered: 1 week ago