Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Linuxkurs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Philip Kaluđerčić
Linuxkurs
Commits
c047271c
Verified
Commit
c047271c
authored
1 month ago
by
Philip Kaluđerčić
Committed by
Philip Kaluđerčić
4 weeks ago
Browse files
Options
Downloads
Patches
Plain Diff
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
4 weeks ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
skripte/aufgabe_killme/tetris
+22
-2
22 additions, 2 deletions
skripte/aufgabe_killme/tetris
with
22 additions
and
2 deletions
skripte/aufgabe_killme/tetris
+
22
−
2
View file @
c047271c
...
...
@@ -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);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment