Question: Write a C program that uses two processes (not threads) to sort the regular files in a directory and th e sub-directories based on file

Write a C program that uses two processes (not threads) to sort the regular files in a directory and th e sub-directories based on file sizes. The program spawns one process (i.e., child process) to scan the directory and the sub-directories for regular files. When the (child) process finds a regular file, it obtains the size, and sends the size and the pathname of the file to the parent process through a FIFO (named pipe) . The parent process sorts (in ascending order) and organizes the size and pathname information. When the child process finishes scanning, it notifies the parent process, and the parent process prints out the sizes and pathnames of the files.

To learn how to traverse the files under a directory and its sub-directories

To learn how to check file status

To learn how to create and use multiple processes

To learn how to exchange data between processes using a FIFO

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!