Question: Create a C function with the following capabilities: prog.c: Modify the template program, lookout.c on p. 56-57 with the following additional capabilities a. Repeat

Create a C function with the following capabilities: prog.c: Modify the template program,   6. Once printing is done, your program should terminate. Make sure your condition checking and printing In the terminal where

Create a C function with the following capabilities: prog.c: Modify the template program, "lookout.c" on p. 56-57 with the following additional capabilities a. Repeat the following steps 5 times (this means, after 5 seconds of running, your program should terminate without printing anything if there is no change detected.) i. Wait 1 seconds using "sleep(1)" call ii. Call "stat" system call to extract the file attributes against given files in command line arguments (the lookout.c program in p. 56 may accept up to 10 files). Your program should be able to accept up to 10 files for monitoring. iii. You program should check any changes in any of the following attributes: 1. st_mode 2. st_nlink 3. st_size 4. st_atime 5. st_mtime iv. When your program detects any changes, your program should immediately print out number codes given below and EXIT! 1. Change of st_mode - print 1 2. Change of st_nlink -print 2 3. Change of st_size-print 3 4. Change of st_atime - print 4 5. Change of st_mtime-print 5 Ac Go 6. Once printing is done, your program should terminate. Make sure your condition checking and printing should be done in the above order! Make sure you print number codes in one line (without any newline character)! 7. Example output when you change the file contents (e.g, using vi): 3 4 5 8. If your program prints more than one number code, then place spaces in between. Important: if your program doesn't print the corresponding number codes or if it prints more information than number codes, then your program will fail the tests, and you will get zero point for the tests. If there is no change detected during your program's execution, your program should exit without printing anything. Testing of your program can be done by opening two terminals, and run "lookout" in one terminal and, in another terminal, make some changes to the file contents, file permission modes, number of links, by using a variety of shell commands such as "vi", "chmod", "link", "unlink", etc. In the terminal where "lookout.c" is running, the program should print the assigned code into display and exit. You need to submit prog.c" into codePost.io in the same way as before.

Step by Step Solution

3.51 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Below is an example of a C program progc based on the provided requirements include include include ... View full answer

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 Programming Questions!