From c047271c361c1595483af1a453306ecf85dce457 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic <philip.kaludercic@fau.de> Date: Wed, 30 Apr 2025 12:37:27 +0200 Subject: [PATCH] Hint at how to solve the "killme/tetris" solution --- skripte/aufgabe_killme/tetris | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/skripte/aufgabe_killme/tetris b/skripte/aufgabe_killme/tetris index 323f7bd..b7716c1 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); -- GitLab