aboutsummaryrefslogtreecommitdiffstats
path: root/src/unistd/hcf.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-30 19:07:20 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-30 19:07:20 +0100
commit696fe7805ea302662f1d200990bea6d1d244b45b (patch)
treeb28aa1b5a2573113081299b51b655ea191196caf /src/unistd/hcf.c
parentneedstack: We cannot protect ourself from death by SIGSEGV, the CPU would halt and catch fire. (diff)
downloadslibc-696fe7805ea302662f1d200990bea6d1d244b45b.tar.gz
slibc-696fe7805ea302662f1d200990bea6d1d244b45b.tar.bz2
slibc-696fe7805ea302662f1d200990bea6d1d244b45b.tar.xz
typo + other ways to catch fire
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src/unistd/hcf.c')
-rw-r--r--src/unistd/hcf.c55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/unistd/hcf.c b/src/unistd/hcf.c
index 160fa63..1030e30 100644
--- a/src/unistd/hcf.c
+++ b/src/unistd/hcf.c
@@ -25,7 +25,7 @@
*
* This is a slibc extension.
*
- * @etymology (H)alt and (c)atch (f)rie!
+ * @etymology (H)alt and (c)atch (f)ire!
*
* @since Always.
*/
@@ -35,3 +35,56 @@ void hcf(void)
goto catch_fire;
}
+
+/*** Other fun ways to catch fire include: ***/
+
+/*
+void hcf(void)
+{
+ for (;;);
+}
+
+
+void hcf(void)
+{
+ hcf();
+ "When optimised, tail-recursion is used and it will be be translated to `for (;;);`";
+}
+
+
+#include <setjmp.h>
+void hcf(void)
+{
+ jmp_buf env;
+ setjmp(env);
+ longjmp(env, 0);
+}
+
+
+#include <limits.h>
+void hcf(void)
+{
+ unsigned long long int i = 0;
+ while (i++ != ULLONG_MAX);
+ "This is just for a limited time, but probably too long for you.";
+}
+
+
+#include <signal.h>
+static void __hcf(int signo)
+{
+ signal(signo, __hcf);
+}
+void hcf(void)
+{
+ sigset_t mask;
+ sigfillset(&mask);
+ sigdelset(&mask, SIGSEGV);
+ pthread_sigmask(SIG_SETMASK, &mask, NULL);
+ signal(SIGSEGV, __hcf);
+ if (*(int*)0)
+ abort();
+ "This is perhaps the least flammable way, but the most fun.";
+}
+*/
+