Welcome to The Fiwix Project
A UNIX-like kernel for the i386 architecture
1 /* 2 * fiwix/kernel/syscalls/sigsuspend.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/syscalls.h> 10 #include <fiwix/signal.h> 11 #include <fiwix/process.h> 12 #include <fiwix/errno.h> 13 14 #ifdef __DEBUG__ 15 #include <fiwix/stdio.h> 16 #endif /*__DEBUG__ */ 17 18 int sys_sigsuspend(__sigset_t *mask) 19 { 20 __sigset_t old_mask; 21 int errno; 22 23 #ifdef __DEBUG__ 24 printk("(pid %d) sys_sigsuspend(0x%08x) -> ", current->pid, mask); 25 #endif /*__DEBUG__ */ 26 27 old_mask = current->sigblocked; 28 if(mask) { 29 if((errno = check_user_area(VERIFY_READ, mask, sizeof(__sigset_t)))) { 30 return errno; 31 } 32 current->sigblocked = (int)*mask & SIG_BLOCKABLE; 33 } else { 34 current->sigblocked = 0 & SIG_BLOCKABLE; 35 } 36 sys_pause(); 37 current->sigblocked = old_mask; 38 39 #ifdef __DEBUG__ 40 printk("-EINTR\n"); 41 #endif /*__DEBUG__ */ 42 43 return -EINTR; 44 }