diff --git a/skripte/aufgabe_killme/tetris b/skripte/aufgabe_killme/tetris index 323f7bdb356dae17dc9081af42da812b3455c53b..b7716c1aedf5ba18aceab319b22a24c1d21126b7 100755 --- a/skripte/aufgabe_killme/tetris +++ b/skripte/aufgabe_killme/tetris @@ -8,6 +8,8 @@ #include <stdlib.h> #include <unistd.h> #include <math.h> +#include <time.h> +#include <string.h> #include <signal.h> #include <sys/wait.h> #include <stdbool.h> @@ -24,6 +26,7 @@ #define P_GR 17 #define P_BL 97 #define SELF_NAME "tetris" +#define BLINK(str) "\033[5m" str "\0330[m" static Display *dpy; @@ -53,6 +56,22 @@ int main() case 0: /* child */ break; default: /* parent */ + { + char *msgs[] = { + "Oh no", ", this is not Tetris...", + "\nIt appears an evil daemon is endeavouring to deceive our senses...", + "\nI hear the spectre murmur...", " \"Who KILLs me petrifies their calamity!\"...", + "\nPerhaps an explicit " BLINK("SIG") "nal will re" BLINK("QUIT") "e our predicament\n", + }; + + for (unsigned i = 0; i < sizeof msgs/sizeof 0[msgs]; i++) { + for (unsigned j = 0; j < strlen(msgs[i]); j++) { + fprintf(stderr, "%c", msgs[i][j]); + nanosleep(&(struct timespec) { .tv_nsec = 10000000L }, NULL); + } + nanosleep(&(struct timespec) { .tv_sec = 1 }, NULL); + } + } return EXIT_SUCCESS; } @@ -91,8 +110,9 @@ int main() nice(19); setsid(); signal(SIGHUP, SIG_IGN); - signal(SIGINT, cleanup); - signal(SIGTERM, cleanup); + signal(SIGINT, SIG_IGN); + signal(SIGTERM, SIG_IGN); + signal(SIGQUIT, cleanup); sigemptyset(&block); sigaddset(&block, SIGINT); sigaddset(&block, SIGTERM);