Lab Exercise 1 Revision 1

The due date has been changed from April 18 to April 25, 2022.
Some changes to problem 3 are intended to clarify which output is to be used.

Due: April 25, 2022
Points: 100

Please form a team of 2 or 3. Include the names of all team members in the header comment. One person needs to submit the program; the other team members must submit a short note identifying who turned in the program.

  1. (50 points) Write a program that terminates a second program after a given period of time. Your program is to have the following interface:

    timeout s command …

    When this command is issued, the timeout program is to execute “command ....” After s seconds have passed, timeout is to send a SIGTERM signal to the command timeout is running.

    You must use fork(2) and execve(2) to run the subcommand.

    Don’t forget to check for possible errors, such as a negative number of seconds or no command!

  2. (25 points) Write a program to print the numeric and symbolic names of any signals it receives, and the date and time it is received. For example, if I send the process a signal 1, it must print:

    Fri Sep 19 23:34:19 2022 Received signal 1 (SIGHUP)

    The program should loop until sent signal 9 (SIGKILL). This signal cannot be caught.

  3. (25 points) Write a program that takes the names of two files as arguments. It determines whether these files are links to each other.

    If the files are linked, print

    These files are linked.

    Print this if both files are hard links to the same file, or if both are symbolic links to the same file.

    If file1 is a symbolic link to file2, print

    file1 is a symbolic link to file2.

    Print this only if file2 is a hard link to a file, and file1 is a symbolic link to file1 (or vice versa).

    If the files are not linked, print

    These files are not linked.

    If a system error occurs (for example, a file does not exist), use perror(3) to print the appropriate error message.


UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 150, Operating Systems
Version of April 19, 2022 at 7:24PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh