Programming Problem - Operating Systems - Laboratory 1 | ECS 150, Lab Reports of Operating Systems

Material Type: Lab; Class: Operating Systems; Subject: Engineering Computer Science; University: University of California - Davis; Term: Spring 2008;

Typology: Lab Reports

Pre 2010

Uploaded on 07/30/2009

koofers-user-l50
koofers-user-l50 🇺🇸

5

(1)

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Laboratory 1
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.
Timeout Program (60 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 sseconds 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!
Extending tee (40 points)
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 nis an integer, the copy of the output is to be written to file descriptor n.
So, for example, the command
etee -2
will copy its input to both its standard output and the standard error (which corresponds to file descriptor 2).
Extra Credit Problems
1. (10 points) In the first problem, use the search path as defined by the PATH environment variable to locate
the command.
ECS 150, Operating Systems Spring Quarter 2008
Version of April 15, 2008 at 3:50 PM Page 1

Partial preview of the text

Download Programming Problem - Operating Systems - Laboratory 1 | ECS 150 and more Lab Reports Operating Systems in PDF only on Docsity!

Laboratory 1

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.

Timeout Program (60 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 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!

Extending tee (40 points)

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).

Extra Credit Problems

  1. ( 10 points ) In the first problem, use the search path as defined by the PATH environment variable to locate the command. ECS 150, Operating Systems Spring Quarter 2008 Version of April 15, 2008 at 3:50 PM Page 1