Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Questions are referring to commands in a Linux Virtual Machine terminal and using C language. 2. A C program needs to run the programs ls

Questions are referring to commands in a Linux Virtual Machine terminal and using C language.

2. A C program needs to run the programs ls and date one after the other, in that order. The date program must be started after the ls program has exited.

A programmer starts by trying the following code fragment:

execvp("ls", arguments_ls);

execvp("date", arguments_date);

(a) The programmer tries to fix the bug by changing the above code to (where status is an int):

image text in transcribed

Explain why this still will not work. Then state how to make it work by a suitable change in this last code. Your description of the change should be precise, referring to line numbers in the above code.

1 2 3 4 if (fork() == 0) { /* child */ execvp("ls", arguments_ls); _exit(ERR_EXECVP); wait(&status); } else { /* parent */ execvp("date", arguments_date); _exit(ERR_EXECVP); } 5 6 7 8

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 Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago