
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Class: Operating Systems; Subject: Engineering Computer Science; University: University of California - Davis; Term: Spring 2008;
Typology: Lab Reports
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Due Date : April 27, 2008 Points : 100 These two programming problems will introduce you to systems programming. Although you may use any system to develop the programs on, you must ensure they run on the Linux systems in the CSIF.
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 command ..... 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!
Write a program called etee that takes its standard input and copies it to its standard output, saving a copy in a file. The interface is etee [ -a ] file where file is the file to which the output is to be saved. If the “a” flag is given, the output is to be appended to file. If file has the name “– n ”, where n is an integer, the copy of the output is to be written to file descriptor n. So, for example, the command etee - will copy its input to both its standard output and the standard error (which corresponds to file descriptor 2).