mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	Signals to processes in userspace now work again.
Ugh, how am I going to dispatch signals to processes in the kernel?
This commit is contained in:
		
							parent
							
								
									dd887e158b
								
							
						
					
					
						commit
						c8b308910e
					
				
					 2 changed files with 25 additions and 3 deletions
				
			
		|  | @ -789,7 +789,7 @@ void Process::dispatch_signal(byte signal) | |||
| 
 | ||||
|     if ((ret_cs & 3) == 0) { | ||||
|         // FIXME: Handle send_signal to process currently in kernel code.
 | ||||
|         kprintf("Boo! dispatch_signal with return to %w:%x\n", ret_cs, ret_eip); | ||||
|         kprintf("Boo! dispatch_signal in %s(%u) with return to %w:%x\n", name().characters(), pid(), ret_cs, ret_eip); | ||||
|         ASSERT_NOT_REACHED(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -827,6 +827,8 @@ void Process::dispatch_signal(byte signal) | |||
| 
 | ||||
|     push_value_on_stack(m_return_from_signal_trampoline.get()); | ||||
| 
 | ||||
|     m_pending_signals &= ~(1 << signal); | ||||
| 
 | ||||
|     dbgprintf("signal: Okay, %s(%u) has been primed\n", name().characters(), pid()); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -33,10 +33,17 @@ static int sh_pwd(int, const char**) | |||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static volatile bool g_got_signal = false; | ||||
| 
 | ||||
| void did_receive_signal(int signum) | ||||
| { | ||||
|     printf("\nMy word, I've received a signal with number %d\n", signum); | ||||
|     //exit(0);
 | ||||
|     g_got_signal = true; | ||||
| } | ||||
| 
 | ||||
| void handle_sigint(int signum) | ||||
| { | ||||
|     printf("Interrupt received by sh\n"); | ||||
| } | ||||
| 
 | ||||
| static int sh_busy(int, const char**) | ||||
|  | @ -48,11 +55,14 @@ static int sh_busy(int, const char**) | |||
|     sa.sa_restorer = nullptr; | ||||
|     int rc = sigaction(SIGUSR1, &sa, nullptr); | ||||
|     assert(rc == 0); | ||||
|     printf("listening for SIGUSR1 while looping in userspace...\n"); | ||||
|     printf("listening for signal SIGUSR1 while looping in userspace...\n"); | ||||
|     for (;;) { | ||||
|         for (volatile int i = 0; i < 100000; ++i) | ||||
|             ; | ||||
|         if (g_got_signal) | ||||
|             break; | ||||
|     } | ||||
|     g_got_signal = false; | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
|  | @ -280,6 +290,16 @@ int main(int, char**) | |||
|     g->sid = setsid(); | ||||
|     tcsetpgrp(0, getpgrp()); | ||||
| 
 | ||||
|     { | ||||
|         struct sigaction sa; | ||||
|         sa.sa_handler = handle_sigint; | ||||
|         sa.sa_flags = 0; | ||||
|         sa.sa_mask = 0; | ||||
|         sa.sa_restorer = nullptr; | ||||
|         int rc = sigaction(SIGINT, &sa, nullptr); | ||||
|         assert(rc == 0); | ||||
|     } | ||||
| 
 | ||||
|     int rc = gethostname(g->hostname, sizeof(g->hostname)); | ||||
|     if (rc < 0) | ||||
|         perror("gethostname"); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling