aboutsummaryrefslogtreecommitdiffstats
path: root/OLD/csci4061/110920_breakout/sol1.c
blob: d33b0df2dce5a7496a749b42b0eab4d6c792281e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Recitation Section Number: 9
* Breakout Number: 6
* Audrey Hebert (heber169)
* Qiyu Tian (tian0068)
* Mouhari Mouhamed (mouha003)
* Matt Strapp (strap012)
*/

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <time.h>

void infinitePrint() {

	static int count = 0;
	printf("%ld: Count = %d\n", time(NULL), ++count);
	sleep(1);
}

int main() {

	// ------------------sol1.c-----------------
	// initialize new sigset - sigset_t, sigemptyset
	sigset_t sigset;
	sigemptyset(&sigset);
	// add SIGINT to sigset - sigaddset
	sigaddset(&sigset, SIGINT);
	// block SIGINT - sigprocmask
	sigprocmask(SIG_BLOCK, &sigset, NULL);
	// Do not modify the while loop and infinitePrint()
	// -----------------------------------------

	/* Print infinitely. */
	while (1) infinitePrint();
}