about summary refs log tree commit diff
path: root/src/signal/signal.c
blob: 08902760afc36a825416f5442d465a87b8499388 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <signal.h>
#include <stddef.h>
#include "syscall.h"

int __sigaction(int, const struct sigaction *, struct sigaction *);

void (*signal(int sig, void (*func)(int)))(int)
{
	struct sigaction sa = { .sa_handler = func, .sa_flags = SA_RESTART };
	if (__sigaction(sig, &sa, &sa) < 0)
		return SIG_ERR;
	return sa.sa_handler;
}