CSCI 356 - Operating Systems - Fall 2012
Programming Assignment #1
Learn to utilize the fork, exec, and wait system calls; learn to check program exit status; learn to introduce a time delay in your code; learn to handle command-line arguments; and gain initial experience with parallel code.
Use a Unix-like environment, such as the Chanticleer Virtual Machine, to complete this assignment. Implement a program that repetitively executes another program, specified on the command line, with a time delay between executions. For example:
./repeat 10 5 ps ax
would run the “ps” command with the argument “ax” a total of 10 times, with a 5-second delay between each call to ps. The 5 second delay should start after the previous execution of ps finishes.
The general syntax that should be used when running your program is:
./repeat.py <number of repetitions> <delay> <program to be invoked> [arg1 [arg2 ...]]
If the program to be invoked returns an exit status other than zero (success), your program should terminate immediately instead of continuing to repeat the call.
NOTE: You will need to use either C or Python to implement this program. Implement the time delay using the sleep function in unistd.h, or the equivalent time.sleep() in Python. Both functions take a single argument specifying the number of seconds to sleep.