mirror of https://github.com/redis/redis.git
				
				
				
			TerminateModuleForkChild(): use wait4 for safety.
In theory currently there is only one active child, but the API may change or for bugs in the implementation we may have several (it was like that for years because of a bug). Better to wait for a specific pid and avoid consuing other pending children information.
This commit is contained in:
		
							parent
							
								
									beb1356b5b
								
							
						
					
					
						commit
						82845f8d04
					
				| 
						 | 
					@ -5193,7 +5193,8 @@ void TerminateModuleForkChild(int wait) {
 | 
				
			||||||
    serverLog(LL_NOTICE,"Killing running module fork child: %ld",
 | 
					    serverLog(LL_NOTICE,"Killing running module fork child: %ld",
 | 
				
			||||||
        (long) server.module_child_pid);
 | 
					        (long) server.module_child_pid);
 | 
				
			||||||
    if (kill(server.module_child_pid,SIGUSR1) != -1 && wait) {
 | 
					    if (kill(server.module_child_pid,SIGUSR1) != -1 && wait) {
 | 
				
			||||||
        while(wait3(&statloc,0,NULL) != server.module_child_pid);
 | 
					        while(wait4(server.module_child_pid,&statloc,0,NULL) !=
 | 
				
			||||||
 | 
					              server.module_child_pid);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /* Reset the buffer accumulating changes while the child saves. */
 | 
					    /* Reset the buffer accumulating changes while the child saves. */
 | 
				
			||||||
    server.module_child_pid = -1;
 | 
					    server.module_child_pid = -1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue