Testing Locked Files solution

$25.00

Original Work ?

Download Details:

  • Name: exercise10.zip
  • Type: zip
  • Size: 113.68 KB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (3 votes)

Write a program that tests the existence of a lock on a file. Use the program writelockafile.c to lock a file. When there is a lock on a file, your program (testlock.c) should
print the ID of the process holding the lock. Otherwise, it prints the message File is
not locked. For example, in one window do:
$ touch test-file
$ ./writelockafile test-file
my pid is 5166
locking
locked; hit enter to unlock…
In another window, run:
$ ./testlock test-file
File is locked by 5166
When the file is not locked, you should get:
$ ./testlock test-file
File is not locked
For a non-existent file, you should get:
./testlock non-existent-file
*** No such file or directory
Due date: April 8. This exercise must be done in the C programming language
under Linux (make sure it runs on Ubuntu 16.04 64-bit). Submit a single tar.gz file.
Source code and a make file must be included. You are responsible for the completeness
of your submission. You are responsible for submitting your work on time. Submissions
that do not compile are not accepted.
1