Files
RedBear-OS/tests/signal.c
T
Tibor Nagy d1a424c002 tests: Replace returns with exits in the main functions
This will allow us to redefine the exit function.

For example:
```
#define exit(code) { \
    fprintf(stderr, "%s:%d: exit(%s) in function ‘%s’\n",
        __FILE__, __LINE__, #code, __func__); \
    _exit(code); \
}
```
2019-02-21 12:15:06 +01:00

26 lines
492 B
C

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
void handler(int sig) {
puts("Signal handler called!");
}
int main(void) {
if (signal(SIGUSR1, &handler) == SIG_ERR) {
puts("Signal error!");
printf("%d\n", errno);
exit(EXIT_FAILURE);
}
puts("Raising...");
if (raise(SIGUSR1)) {
puts("Raise error!");
printf("%d\n", errno);
exit(EXIT_FAILURE);
}
puts("Raised.");
}