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):
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 8Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started