|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
will copy its input to both its standard output and the standard error (which corresponds to file descriptor 2).
|You can also obtain a PDF version of this.||Version of April 15, 2008 at 3:50 PM|