summaryrefslogtreecommitdiffstats
path: root/usr/klibc/onexit.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/klibc/onexit.c')
-rw-r--r--usr/klibc/onexit.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/usr/klibc/onexit.c b/usr/klibc/onexit.c
new file mode 100644
index 0000000..15a96b5
--- /dev/null
+++ b/usr/klibc/onexit.c
@@ -0,0 +1,23 @@
+/*
+ * onexit.c
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include "atexit.h"
+
+int on_exit(void (*fctn) (int, void *), void *arg)
+{
+ struct atexit *as = malloc(sizeof(struct atexit));
+
+ if (!as)
+ return -1;
+
+ as->fctn = fctn;
+ as->arg = arg;
+
+ as->next = __atexit_list;
+ __atexit_list = as;
+
+ return 0;
+}