mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:22:43 +00:00 
			
		
		
		
	Add tcsetpgrp()+tcgetpgrp().
One more step on the path to being able to ^C a runaway process. :^)
This commit is contained in:
		
							parent
							
								
									d8f0dd6f3b
								
							
						
					
					
						commit
						621217ffeb
					
				
					 11 changed files with 72 additions and 4 deletions
				
			
		|  | @ -1249,3 +1249,34 @@ int Process::sys$setpgid(pid_t specified_pid, pid_t specified_pgid) | |||
|     process->m_pgid = new_pgid; | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| pid_t Process::sys$tcgetpgrp(int fd) | ||||
| { | ||||
|     auto* handle = fileHandleIfExists(fd); | ||||
|     if (!handle) | ||||
|         return -EBADF; | ||||
|     if (!handle->isTTY()) | ||||
|         return -ENOTTY; | ||||
|     auto& tty = *handle->tty(); | ||||
|     if (&tty != m_tty) | ||||
|         return -ENOTTY; | ||||
|     return tty.pgid(); | ||||
| } | ||||
| 
 | ||||
| int Process::sys$tcsetpgrp(int fd, pid_t pgid) | ||||
| { | ||||
|     if (pgid < 0) | ||||
|         return -EINVAL; | ||||
|     if (get_sid_from_pgid(pgid) != m_sid) | ||||
|         return -EINVAL; | ||||
|     auto* handle = fileHandleIfExists(fd); | ||||
|     if (!handle) | ||||
|         return -EBADF; | ||||
|     if (!handle->isTTY()) | ||||
|         return -ENOTTY; | ||||
|     auto& tty = *handle->tty(); | ||||
|     if (&tty != m_tty) | ||||
|         return -ENOTTY; | ||||
|     tty.set_pgid(pgid); | ||||
|     return 0; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling