container/init: configurable lingering process wait delay
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Test / Create distribution (push) Successful in 33s
				
			
		
			
				
	
				Test / Sandbox (push) Successful in 1m57s
				
			
		
			
				
	
				Test / Hakurei (push) Successful in 2m50s
				
			
		
			
				
	
				Test / Planterette (push) Successful in 3m39s
				
			
		
			
				
	
				Test / Sandbox (race detector) (push) Successful in 3m43s
				
			
		
			
				
	
				Test / Hakurei (race detector) (push) Successful in 4m33s
				
			
		
			
				
	
				Test / Flake checks (push) Successful in 1m16s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Test / Create distribution (push) Successful in 33s
				
			Test / Sandbox (push) Successful in 1m57s
				
			Test / Hakurei (push) Successful in 2m50s
				
			Test / Planterette (push) Successful in 3m39s
				
			Test / Sandbox (race detector) (push) Successful in 3m43s
				
			Test / Hakurei (race detector) (push) Successful in 4m33s
				
			Test / Flake checks (push) Successful in 1m16s
				
			Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
		
							parent
							
								
									b43d104680
								
							
						
					
					
						commit
						940ee00ffe
					
				| @ -68,6 +68,8 @@ type ( | ||||
| 		Args []string | ||||
| 		// Deliver SIGINT to the initial process on context cancellation. | ||||
| 		ForwardCancel bool | ||||
| 		// time to wait for linger processes after death of initial process | ||||
| 		AdoptWaitDelay time.Duration | ||||
| 
 | ||||
| 		// Mapped Uid in user namespace. | ||||
| 		Uid int | ||||
| @ -128,6 +130,14 @@ func (p *Container) Start() error { | ||||
| 		p.SeccompPresets |= seccomp.PresetDenyTTY | ||||
| 	} | ||||
| 
 | ||||
| 	if p.AdoptWaitDelay == 0 { | ||||
| 		p.AdoptWaitDelay = 5 * time.Second | ||||
| 	} | ||||
| 	// to allow disabling this behaviour | ||||
| 	if p.AdoptWaitDelay < 0 { | ||||
| 		p.AdoptWaitDelay = 0 | ||||
| 	} | ||||
| 
 | ||||
| 	p.cmd = exec.CommandContext(ctx, MustExecutable()) | ||||
| 	p.cmd.Args = []string{initName} | ||||
| 	p.cmd.Stdin, p.cmd.Stdout, p.cmd.Stderr = p.Stdin, p.Stdout, p.Stderr | ||||
|  | ||||
| @ -17,9 +17,6 @@ import ( | ||||
| ) | ||||
| 
 | ||||
| const ( | ||||
| 	// time to wait for linger processes after death of initial process | ||||
| 	residualProcessTimeout = 5 * time.Second | ||||
| 
 | ||||
| 	/* intermediate tmpfs mount point | ||||
| 
 | ||||
| 	this path might seem like a weird choice, however there are many good reasons to use it: | ||||
| @ -358,7 +355,7 @@ func Init(prepare func(prefix string), setVerbose func(verbose bool)) { | ||||
| 					msg.Verbosef("initial process exited with status %#x", w.wstatus) | ||||
| 				} | ||||
| 
 | ||||
| 				go func() { time.Sleep(residualProcessTimeout); close(timeout) }() | ||||
| 				go func() { time.Sleep(params.AdoptWaitDelay); close(timeout) }() | ||||
| 			} | ||||
| 		case <-done: | ||||
| 			msg.BeforeExit() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user