add signal api
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#define SIG_DFL -1
|
||||
#define SIG_IGN 0
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum {
|
||||
#define SIG_DFL 0
|
||||
#define SIG_IGN -1
|
||||
|
||||
typedef enum {
|
||||
SIGABRT, // Abort signal from abort(3)
|
||||
SIGALRM, // Timer signal from alarm(2)
|
||||
SIGBUS, // Bus error (bad memory access)
|
||||
@ -44,11 +47,16 @@ enum {
|
||||
SIGXFSZ, // File size limit exceeded (4.2BSD); see setrlimit(2)
|
||||
SIGWINCH, // Window resize signal (4.3BSD, Sun)
|
||||
SIG_INT, // Interrupt from keyboard
|
||||
};
|
||||
LAST
|
||||
} SIGNAL_CODE;
|
||||
|
||||
typedef void (*sighandler_t)(int);
|
||||
typedef void (*signal_handler_t)(int);
|
||||
|
||||
struct signal {
|
||||
int signum;
|
||||
sighandler_t handler;
|
||||
};
|
||||
void signal(SIGNAL_CODE sig_num, void *handler);
|
||||
void kill(int pid, SIGNAL_CODE sig_num);
|
||||
void exec_signal_pending(void);
|
||||
|
||||
struct signal_data {
|
||||
void *handlers[LAST];
|
||||
uint32_t pending;
|
||||
};
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "list.h"
|
||||
#include "memory.h"
|
||||
#include "signal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -23,7 +24,7 @@ struct task {
|
||||
uint8_t uid;
|
||||
struct task *daddy;
|
||||
struct task *child;
|
||||
struct list **signals;
|
||||
struct signal_data signals;
|
||||
struct task *next;
|
||||
struct task *prev;
|
||||
};
|
||||
|
Reference in New Issue
Block a user