Question: 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):

Questions are referring to commands in a Linux Virtual Machine terminal and

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!