程序代写 CMPUT 379, U. of Alberta, course instructor (E. Elmallah). All rights reser

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. Don¡¯t 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 PowCoder代写 加微信 powcoder

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 occurred if ( execlp("/usr/bin/wc", "wc", (char *) 0) < 0 ) //error occurred printf ("Finished processing \n"); University of Alberta examination University of Alberta examination University of Alberta examination University of Alberta examination University of Alberta examination 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com