mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:32:43 +00:00 
			
		
		
		
	Before sys$write returns, check for pending unmasked signals.
If there is one, put the process into a new BlockedSignal state which makes the next scheduler iteration dispatch the signal.
This commit is contained in:
		
							parent
							
								
									8605711f4b
								
							
						
					
					
						commit
						cba05ce75e
					
				
					 2 changed files with 9 additions and 1 deletions
				
			
		|  | @ -978,6 +978,12 @@ ssize_t Process::sys$write(int fd, const void* data, size_t size) | ||||||
|     if (!descriptor) |     if (!descriptor) | ||||||
|         return -EBADF; |         return -EBADF; | ||||||
|     auto nwritten = descriptor->write((const byte*)data, size); |     auto nwritten = descriptor->write((const byte*)data, size); | ||||||
|  |     if (has_unmasked_pending_signals()) { | ||||||
|  |         block(BlockedSignal); | ||||||
|  |         Scheduler::yield(); | ||||||
|  |         if (nwritten == 0) | ||||||
|  |             return -EINTR; | ||||||
|  |     } | ||||||
| #ifdef DEBUG_IO | #ifdef DEBUG_IO | ||||||
|     kprintf("Process::sys$write: nwritten=%u\n", nwritten); |     kprintf("Process::sys$write: nwritten=%u\n", nwritten); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -52,6 +52,7 @@ public: | ||||||
|         BlockedSleep, |         BlockedSleep, | ||||||
|         BlockedWait, |         BlockedWait, | ||||||
|         BlockedRead, |         BlockedRead, | ||||||
|  |         BlockedSignal, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     enum RingLevel { |     enum RingLevel { | ||||||
|  | @ -64,7 +65,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     bool is_blocked() const |     bool is_blocked() const | ||||||
|     { |     { | ||||||
|         return m_state == BlockedSleep || m_state == BlockedWait || m_state == BlockedRead; |         return m_state == BlockedSleep || m_state == BlockedWait || m_state == BlockedRead || m_state == BlockedSignal; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     PageDirectory& page_directory() { return *m_page_directory; } |     PageDirectory& page_directory() { return *m_page_directory; } | ||||||
|  | @ -317,6 +318,7 @@ static inline const char* toString(Process::State state) | ||||||
|     case Process::BlockedSleep: return "Sleep"; |     case Process::BlockedSleep: return "Sleep"; | ||||||
|     case Process::BlockedWait: return "Wait"; |     case Process::BlockedWait: return "Wait"; | ||||||
|     case Process::BlockedRead: return "Read"; |     case Process::BlockedRead: return "Read"; | ||||||
|  |     case Process::BlockedSignal: return "Signal"; | ||||||
|     case Process::BeingInspected: return "Inspect"; |     case Process::BeingInspected: return "Inspect"; | ||||||
|     } |     } | ||||||
|     ASSERT_NOT_REACHED(); |     ASSERT_NOT_REACHED(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling