Files
RedBear-OS/recipes/tests/signals/pthread_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

95 lines
1.6 KiB
C

#include <pthread.h>
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "signals_list.h"
#include "../test_helpers.h"
//test pthread_kill on self
# define INTHREAD 0
# define INMAIN 1
# define SIGTOTEST SIGABRT
int sem1; /* Manual semaphore */
volatile sig_atomic_t handler_called = 0;
int count = 1;
struct signal {
int signum;
};
void handler() {
handler_called = 1;
return;
}
void *a_thread_func( void *arg)
{
struct sigaction act;
act.sa_flags = 0;
act.sa_handler = handler;
sigemptyset(&act.sa_mask);
sigaction(((struct signal *)arg)->signum, &act, 0);
sem1=INMAIN;
while(sem1==INMAIN)
usleep(100000);
// sleep(50);
handler_called=-1;
pthread_exit(0);
return NULL;
}
int pthread_kill_test1(int signum)
{
pthread_t new_th;
sem1=INTHREAD;
struct signal arg;
arg.signum = signum;
int status;
status = pthread_create(&new_th, NULL, a_thread_func, &arg);
ERROR_IF(pthread_create, status, != 0);
while(sem1==INTHREAD)
usleep(100000);
status = pthread_kill(new_th, signum);
ERROR_IF(pthread_kill, status, != 0);
usleep(100000);
sem1=INTHREAD;
while(handler_called==0)
usleep(100000);
ERROR_IF(pthread_kill, handler_called, == -1);
ERROR_IF(pthread_kill, handler_called, == 0);
handler_called = 0;
return EXIT_SUCCESS;
}
int main(){
for (unsigned int i = 0; i < sizeof(signals_list)/sizeof(signals_list[0]); i++)
{
int sig = signals_list[i].signal;
if (sig == SIGKILL || sig == SIGSTOP)
{
continue;
}
pthread_kill_test1(sig);
}
return EXIT_SUCCESS;
}