Copyright Notice: Copyright by CMPUT 379, U. of Alberta, course instructor (E. Elmallah). All rights reserved. Do not post any part on a publicly-available Web site.
Question 2 (v1) [8 points] The C program fragment shown below is intended to redirect the standard output of the calendar program cal to the standard input of the word counting program wc.
1. Complete the code below. Use pipes for communications. You may assume that all valid system calls are successful. Dont use either the system() or the popen() system calls.
2. Explain the circumstances under which the program writes the line Finished process- ing.
Copyright By Assignmentchef assignmentchef
int main (int argc, char *argv[]) {
pid_t pid;
if ((pid= fork()) < 0)if (pid > 0) {
//error occurred
if (execlp(/usr/bin/cal, cal, 2022, (char *) 0) < 0) //error occurredif ( execlp(“/usr/bin/wc”, “wc”, (char *) 0) < 0 )//error occurredprintf (“Finished processing
“);University of Alberta examination University of Alberta examinationUniversity of Alberta examinationUniversity of Alberta examination University of Alberta examination CS: assignmentchef QQ: 1823890830 Email: [email protected]
Reviews
There are no reviews yet.