diff options
| author | Jakob Kaivo <jkk@ung.org> | 2020-08-16 14:00:51 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2020-08-16 14:00:51 -0400 |
| commit | 896e28812c51b9ffdf3efc00c7d7ef699e380a58 (patch) | |
| tree | aaa25e093fb4a2ac4c57609e1f745e5ac0734ca8 /src/signal | |
| parent | 0b0d1fe1d4fbf8560577d81e5af0549683eac8ba (diff) | |
formatting
Diffstat (limited to 'src/signal')
| -rw-r--r-- | src/signal/SIGABRT.c | 5 | ||||
| -rw-r--r-- | src/signal/SIGFPE.c | 4 | ||||
| -rw-r--r-- | src/signal/SIGILL.c | 4 | ||||
| -rw-r--r-- | src/signal/SIGINT.c | 5 | ||||
| -rw-r--r-- | src/signal/SIGSEGV.c | 4 | ||||
| -rw-r--r-- | src/signal/SIGTERM.c | 5 | ||||
| -rw-r--r-- | src/signal/SIG_DFL.c | 4 | ||||
| -rw-r--r-- | src/signal/SIG_ERR.c | 2 | ||||
| -rw-r--r-- | src/signal/SIG_IGN.c | 2 | ||||
| -rw-r--r-- | src/signal/raise.c | 21 | ||||
| -rw-r--r-- | src/signal/sig_atomic_t.c | 3 | ||||
| -rw-r--r-- | src/signal/signal.c | 23 |
12 files changed, 47 insertions, 35 deletions
diff --git a/src/signal/SIGABRT.c b/src/signal/SIGABRT.c index ce42a249..918a1f5d 100644 --- a/src/signal/SIGABRT.c +++ b/src/signal/SIGABRT.c @@ -1,11 +1,14 @@ -#include <signal.h> #define SIGABRT (6) + /** abnormal termination **/ + /*** is a signal indicating that the program is being terminated abnormally, such as when FUNCTION(abort) is called. ***/ + /* Value selected to match requirements for COMMAND(kill) and COMMAND(trap). */ + /* STDC(1) */ diff --git a/src/signal/SIGFPE.c b/src/signal/SIGFPE.c index 995a21c2..b4d56e09 100644 --- a/src/signal/SIGFPE.c +++ b/src/signal/SIGFPE.c @@ -1,10 +1,12 @@ -#include <signal.h> #define SIGFPE (4) + /** floating point exception **/ + /*** is a signal that indicates an error resulting from invalid arithmetic operations, such as division by zero or overflows. ***/ + /* STDC(1) */ diff --git a/src/signal/SIGILL.c b/src/signal/SIGILL.c index bd6afce8..b1ae8219 100644 --- a/src/signal/SIGILL.c +++ b/src/signal/SIGILL.c @@ -1,10 +1,12 @@ -#include <signal.h> #define SIGILL (5) + /** illegal instruction **/ + /*** is a signal indicating that the program has attempted to execute an illegal or improperly formed instruction. ***/ + /* STDC(1) */ diff --git a/src/signal/SIGINT.c b/src/signal/SIGINT.c index d335bbe2..bdd3f74d 100644 --- a/src/signal/SIGINT.c +++ b/src/signal/SIGINT.c @@ -1,10 +1,13 @@ -#include <signal.h> #define SIGINT (2) + /** interrupt **/ + /*** is a signal that indicates the program is being interactively interrupted. ***/ + /* Value selected to match requirements for COMMAND(kill) and COMMAND(trap). */ + /* STDC(1) */ diff --git a/src/signal/SIGSEGV.c b/src/signal/SIGSEGV.c index cfda42c2..dfb5adf1 100644 --- a/src/signal/SIGSEGV.c +++ b/src/signal/SIGSEGV.c @@ -1,10 +1,12 @@ -#include <signal.h> #define SIGSEGV (7) + /** segmentation fault **/ + /*** is a signal that indicates the program is attempting to access an invalid memory address. ***/ + /* STDC(1) */ diff --git a/src/signal/SIGTERM.c b/src/signal/SIGTERM.c index 72dfa7ae..4e475279 100644 --- a/src/signal/SIGTERM.c +++ b/src/signal/SIGTERM.c @@ -1,10 +1,13 @@ -#include <signal.h> #define SIGTERM (15) + /** terminate **/ + /*** is a signal indicating that the system is requesting the program to terminate. ***/ + /* Value selected to match requirements for COMMAND(kill) and COMMAND(trap). */ + /* STDC(1) */ diff --git a/src/signal/SIG_DFL.c b/src/signal/SIG_DFL.c index 549fe6e4..e067921a 100644 --- a/src/signal/SIG_DFL.c +++ b/src/signal/SIG_DFL.c @@ -1,10 +1,12 @@ -#include <signal.h> #define SIG_DFL ((void(*)(int))-1) + /** default signal action **/ + /*** is used as the ARGUMENT(func) argument to FUNCTION(signal) to indicate that the default signal action should occur. ***/ + /* STDC(1) */ diff --git a/src/signal/SIG_ERR.c b/src/signal/SIG_ERR.c index 0200a72f..62690293 100644 --- a/src/signal/SIG_ERR.c +++ b/src/signal/SIG_ERR.c @@ -1,4 +1,3 @@ -#include <signal.h> #define SIG_ERR ((void(*)(int))-2) /** error setting signal handler **/ @@ -7,6 +6,7 @@ is a sentinal value returned by FUNCTION(signal) to indicate that an error occurred. ***/ + /* STDC(1) */ diff --git a/src/signal/SIG_IGN.c b/src/signal/SIG_IGN.c index a753adc7..ad229f0d 100644 --- a/src/signal/SIG_IGN.c +++ b/src/signal/SIG_IGN.c @@ -1,4 +1,3 @@ -#include <signal.h> #define SIG_IGN ((void(*)(int))-3) /** ignore signal **/ @@ -7,6 +6,7 @@ can be used as the ARGUMENT(func) argument in a call to FUNCTION(signal) to ignore the specified signal. ***/ + /* STDC(1) */ diff --git a/src/signal/raise.c b/src/signal/raise.c index 04bed498..08e58747 100644 --- a/src/signal/raise.c +++ b/src/signal/raise.c @@ -1,14 +1,20 @@ -#if defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || defined _XOPEN_SOURCE -#include "sys/types.h" -#include "unistd.h" -#else -#include "_syscall.h" -#define kill(pid, sig) __syscall(__syscall_lookup(kill), pid, sig) -#define getpid() __syscall(__syscall_lookup(getpid)) +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE +#define POSIX_FORCED #endif + +#include <sys/types.h> #include <signal.h> +#include <unistd.h> + +#ifdef POSIX_FORCED +#include "_syscall.h" +#define kill(pid, sig) __scall2(kill, pid, sig) +#define getpid() __scall0(getpid) +#endif /** send a signal to the current program **/ + int raise(int sig) { /* @@ -25,6 +31,7 @@ int raise(int sig) /*** sends the signal ARGUMENT(sig) to the current program. ***/ + /* STDC(1) */ diff --git a/src/signal/sig_atomic_t.c b/src/signal/sig_atomic_t.c index b3ec2a84..c881018c 100644 --- a/src/signal/sig_atomic_t.c +++ b/src/signal/sig_atomic_t.c @@ -1,4 +1,3 @@ -#include <signal.h> typedef volatile int sig_atomic_t; /** non-interruptible type **/ @@ -9,7 +8,5 @@ is a type of object that can be used atomically even in the presence of interrup /* TYPEDEF(integer) -*/ -/* STDC(1) */ diff --git a/src/signal/signal.c b/src/signal/signal.c index afeacc84..5f25269f 100644 --- a/src/signal/signal.c +++ b/src/signal/signal.c @@ -1,25 +1,18 @@ -#if defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || defined _XOPEN_SOURCE -#include "sys/types.h" +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE +#define POSIX_FORCED #endif -#include "stddef.h" +#include <sys/types.h> +#include <stddef.h> #include <signal.h> -#ifndef _POSIX_SOURCE -#include "sigset_t.c" -#include "struct_sigaction.c" -#include "sigaction.c" -#include "sigemptyset.c" -#include "sigaddset.c" -#endif - +/* FIXME: Linux specific, doesn't even work */ #undef SA_RESTART -#ifndef SA_RESTART -/* #include "SA_RESTART.c" */ #define SA_RESTART 0x10000000 -#endif /** set a signal handler **/ + void (*signal(int sig, void (*func)(int)))(int) { struct sigaction sa = { 0 }, osa = { 0 }; @@ -60,7 +53,5 @@ UNDEFINED(A signal handler calling standard library functions other than THIS() UNDEFINED(FIXME: some function calls from signal handlers) IMPLEMENTATION(Whether signal blocking is performed when a signal occurs) IMPLEMENTATION(Other signals corresponding to computation exceptions for which signal handlers must not return) -*/ -/* STDC(1) */ |
