Files
RedBear-OS/recipes/tests/signals/kill-self.c
T
vasilito b9874d0941 feat: USB storage read/write proof + full Red Bear OS tree sync
Add redbear-usb-storage-check in-guest binary that validates USB mass
storage read and write I/O: discovers /scheme/disk/ devices, writes a
test pattern to sector 2048, reads it back, verifies match, restores
original content. Updates test-usb-storage-qemu.sh with write-proof
verification step.

Includes all accumulated Red Bear OS work: kernel patches, relibc
patches, driver infrastructure, DRM/GPU, KDE recipes, firmware,
validation tooling, build system hardening, and documentation.
2026-05-03 23:03:24 +01:00

57 lines
975 B
C

#include <assert.h>
#include <signal.h>
#include "signals_list.h"
#include "../test_helpers.h"
/*
* Test signal catching when signalling self.
* Ensure all signals can be caught (other than SIGKILL and SIGSTOP).
*/
volatile sig_atomic_t handler_called = 0;
void sig_handler(int sig)
{
(void) sig;
handler_called = 1;
}
int kill_self(int sig)
{
struct sigaction act;
int status;
handler_called = 0;
act.sa_handler = sig_handler;
act.sa_flags = 0;
status = sigemptyset(&act.sa_mask);
ERROR_IF(sigemptyset, status, == -1);
status = sigaction(sig, &act, NULL);
ERROR_IF(sigaction, status, == -1);
status = kill(getpid(), sig);
ERROR_IF(kill, status, != 0);
assert(handler_called == 1);
return EXIT_SUCCESS;
}
int main()
{
for (unsigned int i = 1; i < sizeof(signals_list)/sizeof(signals_list[0]); i++)
{
int sig = signals_list[i].signal;
if (sig == SIGKILL || sig == SIGSTOP)
{
continue;
}
kill_self(sig);
}
return EXIT_SUCCESS;
}