Piping and forks | Computer Science homework help

1. Carefully study the examples described in class: fork.c, myls.c, myshell.c, etc.. You need to know how they work in order for you to finish this assignment; the examples will also get you prepared for major assignment 3.

2. Write a program that creates two child processes: one to execute ‘ls’ and the other to execute ‘sort’. After the forks, the original parent process waits for both child processes to finish before it terminates. The standard output of ‘ls’ process should be piped to the input to the ‘sort’ process. Make sure you close the unnecessary open files for the three processes. 

Please follow the following instructions carefully before submitting your work:

* Create a directory for this homework, call it ‘firstname-lastname-offhand-3’. Under this directory, you put your source code and the Makefile.

* You need to create a Makefile to build your source code into an executable. The Makefile should also include a target ‘clean’ to clean up miscellaneous files (*.o, the executable file, *~, core, etc.). Before submission, make sure you clean up the directories so that no miscellaneous files are kept around in the submission. (Grade would be deducted if useless files are found in the homework directories.)

The file to be submitted should be named as ‘firstname-lastname-offhand-3.zip and submitted in Moodle.

NOTE THAT ALL HOMEWORK IS INDIVIDUAL WORK. NO CODE SHARING AND CO-DEVELOPMENT IS EVER ALLOWED. REFER TO CODE OF CONDUCT STATED IN SYLLABUS. ZERO TOLERANCE FOR ETHIC VIOLATIONS IN THIS COURSE.