-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathsignal_event.c
51 lines (45 loc) · 1.1 KB
/
signal_event.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "el.h"
//全局信号链表
sig_event_list sig_list;
sig_event *sig_event_init(event *e, int signo) {
sig_event *se = (sig_event*) malloc(sizeof(sig_event));
init_pipe(se->pipe);
se->signo = signo;
se->sevent = e;
init_signal(se);
sig_event_list_add(&sig_list, se);
e->type = SIGNAL;
return se;
}
void sig_event_free(sig_event *sig) {
free(sig);
}
void sig_event_list_init(sig_event_list *list) {
list->head = (sig_event*) malloc(sizeof(sig_event));
list->head->next = list->head;
list->head->prev = list->head;
list->count = 0;
}
void sig_event_list_add(sig_event_list *list, sig_event *e) {
list->count++;
e->next = list->head->next;
list->head->next->prev = e;
e->prev = list->head;
list->head->next = e;
}
sig_event *find_sigevent(sig_event_list *list, int no) {
int count = list->count;
int i;
sig_event *first = list->head;
sig_event *ret;
for (i = 0; i < count; i++) {
if (first->next->signo == no) {
ret = first->next;
first->next = ret->next;
ret->next->prev = first;
return ret;
}
first = first->next;
}
return NULL;
}