]> git.sur5r.net Git - cc65/commitdiff
Added signal-test.c
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 16 Mar 2003 14:27:24 +0000 (14:27 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sun, 16 Mar 2003 14:27:24 +0000 (14:27 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2023 b7a2c559-68d2-44c3-8de9-860c34a00d81

testcode/lib/files.txt
testcode/lib/signal-test.c [new file with mode: 0644]

index f89751b33cdf2b649df6c0eba66575fcb728a588..232fbb2ad57feadfc379ebdf8b7f646d807b27e4 100644 (file)
@@ -14,4 +14,5 @@ getsp.s               -       helper routine for ft.c
 joy-test.c             -       joystick driver test program
 posixio-test.c  -       test POSIX file i/o routines (open/read/write/close)
 seek.c         -       test lseek()/fseek()/ftell()
+signal-test.c   -       small test program for signal/raise
 time-test.c     -       test the time/mktime/gmtime/asctime functions
diff --git a/testcode/lib/signal-test.c b/testcode/lib/signal-test.c
new file mode 100644 (file)
index 0000000..4e34a28
--- /dev/null
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+
+
+void __fastcall__ sighandler (int sig)
+{
+    printf ("Got signal #%d\n", sig);
+}
+
+
+
+int main (void)
+{
+    if (signal (SIGSEGV, sighandler) == SIG_ERR) {
+        printf ("signal failure %d: %s\n", errno, strerror (errno));
+        return 1;
+    }
+    printf ("About to raise SIGSEGV...\n");
+    raise (SIGSEGV);
+    printf ("Back from signal handler\n");
+    printf ("About to raise SIGILL...\n");
+    raise (SIGILL);
+    printf ("Back from signal handler\n");
+    return 0;
+}
+
+