-
Notifications
You must be signed in to change notification settings - Fork 46
/
do_sigprocmask.c
71 lines (61 loc) · 1.48 KB
/
do_sigprocmask.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <kernel/kernel.h>
#include <winix/ksignal.h>
/**
* Syscall in this file: sigprocmask
* Input: m1_i1: how
* m1_i2: set
*
* Return: m1_i2: old set;
*
* @author Bruce Tan
* @email brucetansh@gmail.com
*
* @author Paul Monigatti
* @email paulmoni@waikato.ac.nz
*
* @create date 2017-08-23 06:10:17
*
*/
int do_sigprocmask(struct proc* who, struct message* m){
sigset_t set;
sigset_t *pset, *pblocked;
int i;
int how = m->m1_i1;
vptr_t *vir_oldact;
ptr_t *oldact;
vir_oldact = m->m1_p1;
if(vir_oldact && !is_vaddr_accessible(vir_oldact, who))
return -EFAULT;
if(vir_oldact){
oldact = get_physical_addr(vir_oldact, who);
*oldact = who->sig_mask;
}
set = m->m1_i2;
pset = &set;
pblocked = &who->sig_mask;
sigdelset(pset, SIGKILL);
sigdelset(pset, SIGSTOP);
switch(how){
case SIG_SETMASK:
who->sig_mask = set;
// kdebug("set sigmask %x for %d\n", set, who->pid);
break;
case SIG_BLOCK:
for( i = 1; i < _NSIG; i++){
if(sigismember(pset, i)){
sigaddset(pblocked, i);
}
}
break;
case SIG_UNBLOCK:
for( i = 1; i < _NSIG; i++){
if(sigismember(pset, i)){
sigdelset(pblocked, i);
}
}
break;
default:
return -EINVAL;
}
return 0;
}