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
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