From: kremlin Date: Tue, 4 Nov 2014 01:22:30 +0000 (-0500) Subject: write lab5 X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?a=commitdiff_plain;h=3c8bdb99ac2775d84d1af797fbf77d7c712ad426;p=assignments.git write lab5 --- diff --git a/lab/lab5/Makefile b/lab/lab5/Makefile index fec97f3..1c5cf8d 100644 --- a/lab/lab5/Makefile +++ b/lab/lab5/Makefile @@ -1,8 +1,8 @@ .PHONY: all cc=/usr/bin/gcc -CARGS=-Wall -Werror -Wextra -pedantic -Wno-unused-parameter -Wno-unused -std=c99 -SRC=zombie.c -o zombie +CARGS=-Wall -Werror -Wextra -pedantic -Wno-unused-parameter -Wno-unused -std=c99 -lrt +SRC=sleep.c -o sleep all: $(CC) $(CARGS) $(SRC) diff --git a/lab/lab5/sleep.c b/lab/lab5/sleep.c new file mode 100644 index 0000000..8ebeb3e --- /dev/null +++ b/lab/lab5/sleep.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +void request_denied() { + + printf("no\n"); + signal(SIGTSTP, request_denied); +} + +int main(int argc, char *argv[]) { + + int seconds_left; + + signal(SIGTSTP, request_denied); + + seconds_left = sleep(5); + + while(seconds_left != 0) + seconds_left = sleep(seconds_left); + + + + return 0; +}