Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hi can someone help me ammed this code so that it does the following instead? The following are the major tasks you need to perform:

hi can someone help me ammed this code so that it does the following instead? image text in transcribed
image text in transcribed
The following are the major tasks you need to perform: 1. The first program is called simple_shell and it is included in the file named simple shell.cpp. The program reads a shell command from the user and executes it using the system call execvp. The program is designed to execute one command and then exits. What you need to do is to make the program run forever using an infinite loop, until a termination condition is triggered. Within the loop the program should execute in the following sequence: 1. Read command from user. [Already provided] 2. Cut up the command into argument list. [Already Provided] 3. If the command is equivalent to "exit" break the loop and exit; you can use strcasecmp to check that. Else fork a new child to execute the command and wait for the child until it finishes 4. 5. The child should use execvp. [Already provided] 6. Repeat the sequence again. include include include include ) fgets (command, 1000,stdin)i if (command[ strlen (command)-11 n) command[strlen( command)-1) 10' int arg count getArgumentsCount (command) i arg (char*) calloc (arg count+1,sizeof(char)) argarg count] NULL: setArguments (command, arg) if ( execvp (argt0]1,arg) 0 perror("exeevp") free (arg)i return 12

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_2

Step: 3

blur-text-image_3

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

Students also viewed these Databases questions