* Don't count on the Pid deconstructor to kill the child process,
since if we're running a build user in non-root mode, we can't. Let the setuid helper do it.
This commit is contained in:
		
							parent
							
								
									a82d80ddeb
								
							
						
					
					
						commit
						c3286ec020
					
				
					 1 changed files with 14 additions and 2 deletions
				
			
		| 
						 | 
					@ -653,12 +653,24 @@ DerivationGoal::DerivationGoal(const Path & drvPath, Worker & worker)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DerivationGoal::~DerivationGoal()
 | 
					DerivationGoal::~DerivationGoal()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (pid != -1) worker.childTerminated(pid);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    /* Careful: we should never ever throw an exception from a
 | 
					    /* Careful: we should never ever throw an exception from a
 | 
				
			||||||
       destructor. */
 | 
					       destructor. */
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
 | 
					        if (pid != -1) {
 | 
				
			||||||
 | 
					            worker.childTerminated(pid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (buildUser.enabled()) {
 | 
				
			||||||
 | 
					                /* Can't let pid's destructor do it, since it may not
 | 
				
			||||||
 | 
					                   have the appropriate privilege (i.e., the setuid
 | 
				
			||||||
 | 
					                   helper should do it). */
 | 
				
			||||||
 | 
					                buildUser.kill();
 | 
				
			||||||
 | 
					                pid.wait(true);
 | 
				
			||||||
 | 
					                assert(pid == -1);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        deleteTmpDir(false);
 | 
					        deleteTmpDir(false);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
    } catch (Error & e) {
 | 
					    } catch (Error & e) {
 | 
				
			||||||
        printMsg(lvlError, format("error (ignored): %1%") % e.msg());
 | 
					        printMsg(lvlError, format("error (ignored): %1%") % e.msg());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue