aboutsummaryrefslogtreecommitdiff
path: root/c/atexit/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/atexit/main.c')
-rw-r--r--c/atexit/main.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/c/atexit/main.c b/c/atexit/main.c
new file mode 100644
index 0000000..1729edf
--- /dev/null
+++ b/c/atexit/main.c
@@ -0,0 +1,33 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static void *loop(void *);
+static void handler(void);
+
+int
+main(void)
+{
+ pthread_t t;
+
+ atexit(handler);
+ pthread_create(&t, NULL, loop, NULL);
+ sleep(1);
+ return EXIT_SUCCESS;
+}
+
+void *
+loop(void *_)
+{
+ (void)_;
+ for (;;)
+ ;
+ return NULL;
+}
+
+void
+handler(void)
+{
+ puts("hello, world!");
+}