CS 355 - Systems Programming Lab 8 - using signal()
Objective: write a program that provides a custom handler for the interrupt signal.
- Write a C program prime that uses a brute force approach to find prime numbers.
- prime needs to keep track of the largest prime number found so far.
- Use the signal() function to provide a custom handler for the SIGINT signal.
- When Ctrl-C is pressed, prime needs to do the following:
- Print the largest prime number found so far;
- Prompt the user whether to quit;
- Accept exactly one character as the input without requiring the user to press Enter;
- Quit if the user presses y or Y.
- Typical output generated by prime will look as follows:
$ prime
17 Quit [y/n]? n
271 Quit [y/n]? z
521 Quit [y/n]? N
1061 Quit [y/n]? n
1783 Quit [y/n]? y
$
- A single C source code file with your work.
- A screenshot (in PNG or JPG format) showing the output of prime.