write lab5
authorkremlin <ian@kremlin.cc>
Tue, 4 Nov 2014 01:22:30 +0000 (20:22 -0500)
committerkremlin <ian@kremlin.cc>
Tue, 4 Nov 2014 01:22:30 +0000 (20:22 -0500)
lab/lab5/Makefile
lab/lab5/sleep.c [new file with mode: 0644]

index fec97f3f428702faf5fd7e2e80253b7186018d84..1c5cf8d25854e51f4486eb2cdfa65b5f4e08fa2f 100644 (file)
@@ -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 (file)
index 0000000..8ebeb3e
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+
+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;
+}