mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:32:45 +00:00 
			
		
		
		
	Shell: Put children in their own process groups and fix job control
This commit fixes job control by putting children in their own process group, and proxying TTY signals to active jobs. This also cleans up the code around builtin_disown a bit to use the newer job interfaces.
This commit is contained in:
		
							parent
							
								
									3a7a689b87
								
							
						
					
					
						commit
						151e4d41ed
					
				
					 5 changed files with 49 additions and 35 deletions
				
			
		|  | @ -62,16 +62,21 @@ int main(int argc, char** argv) | |||
| 
 | ||||
|     Core::EventLoop::register_signal(SIGINT, [](int) { | ||||
|         editor->interrupted(); | ||||
|         s_shell->kill_job(s_shell->current_job(), SIGINT); | ||||
|     }); | ||||
| 
 | ||||
|     Core::EventLoop::register_signal(SIGWINCH, [](int) { | ||||
|         editor->resized(); | ||||
|         s_shell->kill_job(s_shell->current_job(), SIGWINCH); | ||||
|     }); | ||||
| 
 | ||||
|     Core::EventLoop::register_signal(SIGTTIN, [](int) {}); | ||||
|     Core::EventLoop::register_signal(SIGTTOU, [](int) {}); | ||||
| 
 | ||||
|     Core::EventLoop::register_signal(SIGHUP, [](int) { | ||||
|         for (auto& it : s_shell->jobs) | ||||
|             s_shell->kill_job(it.value.ptr(), SIGHUP); | ||||
| 
 | ||||
|         s_shell->save_history(); | ||||
|     }); | ||||
| 
 | ||||
|  | @ -102,6 +107,8 @@ int main(int argc, char** argv) | |||
|                     job.value->set_has_exit(WEXITSTATUS(wstatus)); | ||||
|                 } else if (WIFSIGNALED(wstatus) && !WIFSTOPPED(wstatus)) { | ||||
|                     job.value->set_has_exit(126); | ||||
|                 } else if (WIFSTOPPED(wstatus)) { | ||||
|                     job.value->unblock(); | ||||
|                 } | ||||
|             } | ||||
|             if (job.value->should_be_disowned()) | ||||
|  | @ -111,8 +118,12 @@ int main(int argc, char** argv) | |||
|             jobs.remove(key); | ||||
|     }); | ||||
| 
 | ||||
|     // Ignore SIGTSTP as the shell should not be suspended with ^Z.
 | ||||
|     Core::EventLoop::register_signal(SIGTSTP, [](auto) {}); | ||||
|     Core::EventLoop::register_signal(SIGTSTP, [](auto) { | ||||
|         auto job = s_shell->current_job(); | ||||
|         s_shell->kill_job(job, SIGTSTP); | ||||
|         if (job) | ||||
|             job->unblock(); | ||||
|     }); | ||||
| 
 | ||||
| #ifndef __serenity__ | ||||
|     sigset_t blocked; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AnotherTest
						AnotherTest