LibC: Rewrite sigprocmask in terms of pthread_sigmask
Also don't fail SYS_SIGPROCMASK if how is invalid and set is NULL.
This commit is contained in:
		
							parent
							
								
									2ca7886f88
								
							
						
					
					
						commit
						7afdfb150f
					
				|  | @ -1826,16 +1826,6 @@ namespace Kernel | |||
| 
 | ||||
| 	BAN::ErrorOr<long> Process::sys_sigprocmask(int how, const sigset_t* set, sigset_t* oset) | ||||
| 	{ | ||||
| 		switch (how) | ||||
| 		{ | ||||
| 			case SIG_BLOCK: | ||||
| 			case SIG_SETMASK: | ||||
| 			case SIG_UNBLOCK: | ||||
| 				break; | ||||
| 			default: | ||||
| 				return BAN::Error::from_errno(EINVAL); | ||||
| 		} | ||||
| 
 | ||||
| 		LockGuard _(m_process_lock); | ||||
| 		if (set) | ||||
| 			TRY(validate_pointer_access(set, sizeof(sigset_t))); | ||||
|  | @ -1857,8 +1847,10 @@ namespace Kernel | |||
| 					Thread::current().m_signal_block_mask  = mask; | ||||
| 					break; | ||||
| 				case SIG_UNBLOCK: | ||||
| 					Thread::current().m_signal_block_mask &= mask; | ||||
| 					Thread::current().m_signal_block_mask &= ~mask; | ||||
| 					break; | ||||
| 				default: | ||||
| 					return BAN::Error::from_errno(EINVAL); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  |  | |||
|  | @ -19,6 +19,11 @@ void psignal(int signum, const char* message) | |||
| 		fprintf(stderr, "%s\n", strsignal(signum)); | ||||
| } | ||||
| 
 | ||||
| int pthread_sigmask(int how, const sigset_t* __restrict set, sigset_t* __restrict oset) | ||||
| { | ||||
| 	return syscall(SYS_SIGPROCMASK, how, set, oset); | ||||
| } | ||||
| 
 | ||||
| int raise(int sig) | ||||
| { | ||||
| 	// FIXME: won't work after multithreaded
 | ||||
|  | @ -72,5 +77,5 @@ int sigpending(sigset_t* set) | |||
| 
 | ||||
| int sigprocmask(int how, const sigset_t* __restrict set, sigset_t* __restrict oset) | ||||
| { | ||||
| 	return syscall(SYS_SIGPROCMASK, how, set, oset); | ||||
| 	return pthread_sigmask(how, set, oset); | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue