Welcome to The Fiwix Project
A UNIX-like kernel for the i386 architecture
1 /* 2 * fiwix/kernel/syscalls/sigprocmask.c 3 * 4 * Copyright 2018, Jordi Sanfeliu. All rights reserved. 5 * Distributed under the terms of the Fiwix License. 6 */ 7 8 #include <fiwix/fs.h> 9 #include <fiwix/signal.h> 10 #include <fiwix/process.h> 11 #include <fiwix/errno.h> 12 13 #ifdef __DEBUG__ 14 #include <fiwix/stdio.h> 15 #endif /*__DEBUG__ */ 16 17 int sys_sigprocmask(int how, const __sigset_t *set, __sigset_t *oldset) 18 { 19 int errno; 20 21 #ifdef __DEBUG__ 22 printk("(pid %d) sys_sigprocmask(%d, 0x%08x, 0x%08x)\n", current->pid, how, set, oldset); 23 #endif /*__DEBUG__ */ 24 25 if(oldset) { 26 if((errno = check_user_area(VERIFY_WRITE, oldset, sizeof(__sigset_t)))) { 27 return errno; 28 } 29 *oldset = current->sigblocked; 30 } 31 32 if(set) { 33 if((errno = check_user_area(VERIFY_READ, set, sizeof(__sigset_t)))) { 34 return errno; 35 } 36 switch(how) { 37 case SIG_BLOCK: 38 current->sigblocked |= (*set & SIG_BLOCKABLE); 39 break; 40 case SIG_UNBLOCK: 41 current->sigblocked &= ~(*set & SIG_BLOCKABLE); 42 break; 43 case SIG_SETMASK: 44 current->sigblocked = (*set & SIG_BLOCKABLE); 45 break; 46 default: 47 return -EINVAL; 48 } 49 } 50 return 0; 51 }