Skip to content
Snippets Groups Projects
Verified Commit c047271c authored by Philip Kaluđerčić's avatar Philip Kaluđerčić :u7121: Committed by Philip Kaluđerčić
Browse files

Hint at how to solve the "killme/tetris" solution

parent 5c1b2478
No related branches found
No related tags found
No related merge requests found
Pipeline #179435 passed
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment