rem: if (sig_mask) { for (i = 0; i < NSIG; i++) { if (sig_mask & 0x1) {  sig = i + 1; handler = &t->sig_action[i]; sig_mask >>= 1; t->sig_pending &= ~(1L << i);  dprintf("Thread 0x%lx received signal %s\n", t->id, sigstr[sig]);  if (handler->sa_handler == SIG_IGN) {   continue;
add: if (signalMask == 0) return 0;  for (i = 0; i < NSIG; i++) { if (signalMask & 0x1) { sig = i + 1; handler = &thread->sig_action[i]; signalMask >>= 1; thread->sig_pending &= ~(1L << i);  dprintf("Thread 0x%lx received signal %s\n", thread->id, sigstr[sig]);  if (handler->sa_handler == SIG_IGN) {   continue; } if (handler->sa_handler == SIG_DFL) {  switch (sig) { case SIGCHLD: case SIGWINCH: case SIGTSTP: case SIGTTIN: case SIGTTOU: case SIGCONT: continue;  case SIGSTOP: thread->next_state = B_THREAD_SUSPENDED; global_resched = 1; continue;  case SIGQUIT: case SIGILL: case SIGTRAP: case SIGABRT: case SIGFPE: case SIGSEGV: dprintf("Shutting down thread 0x%lx due to signal #%d\n", thread->id, sig); case SIGKILL: case SIGKILLTHR: default: if (!(thread->return_flags & THREAD_RETURN_EXIT)) thread->return_flags |= THREAD_RETURN_INTERRUPTED; RELEASE_THREAD_LOCK(); restore_interrupts(state); thread_exit();
context: handle_signals(struct thread *t, int state){	uint32 sig_mask = t->sig_pending & (~t->sig_block_mask);	int i, sig, global_resched = 0;	struct sigaction *handler;		if (sig_mask) {		for (i = 0; i < NSIG; i++) {			if (sig_mask & 0x1) {								sig = i + 1;				handler = &t->sig_action[i];				sig_mask >>= 1;				t->sig_pending &= ~(1L << i);								dprintf("Thread 0x%lx received signal %s\n", t->id, sigstr[sig]);								if (handler->sa_handler == SIG_IGN) {					// signal is to be ignored					// XXX apply zombie cleaning on SIGCHLD					continue;				}				if (handler->sa_handler == SIG_DFL) {					// default signal behaviour					switch (sig) {						case SIGCHLD:						case SIGWINCH:						case SIGTSTP:						case SIGTTIN:						case SIGTTOU:						case SIGCONT:							continue;												case SIGSTOP:							t->next_state = B_THREAD_SUSPENDED;							global_resched = 1;							continue;																			case SIGQUIT:						case SIGILL:						case SIGTRAP:						case SIGABRT:						case SIGFPE:						case SIGSEGV:							dprintf("Shutting down thread 0x%lx due to signal #%d\n", t->id, sig);						case SIGKILL:						case SIGKILLTHR:						default:							if (!(t->return_flags & THREAD_RETURN_EXIT))								t->return_flags |= THREAD_RETURN_INTERRUPTED;							RELEASE_THREAD_LOCK();							restore_interrupts(state);							thread_exit();					}				}								// User defined signal handler				dprintf("### Setting up custom signal handler frame...\n");				arch_setup_signal_frame(t, handler, sig, t->sig_block_mask);								if (handler->sa_flags & SA_ONESHOT)					handler->sa_handler = SIG_DFL;				if (!(handler->sa_flags & SA_NOMASK))					t->sig_block_mask |= (handler->sa_mask | (1L << sig)) & BLOCKABLE_SIGS;								return global_resched;			} else				sig_mask >>= 1;		}		arch_check_syscall_restart(t);	}	return global_resched;}