Cygwin: fork: attach child not before success
Do not attach to the child before it was successfully initialized, or we
would need more sophisticated cleanup on child initialization failure,
like suppressing SIGCHILD delivery with multiple threads ("waitproc")
involved.
Improves "Cygwin: fork: Remember child not before success.",
commit f03ea8e1c5, which leads to fork
problems if cygserver is running:
https://cygwin.com/ml/cygwin-patches/2019-q2/msg00155.html
			
			
This commit is contained in:
		
				
					committed by
					
						 Corinna Vinschen
						Corinna Vinschen
					
				
			
			
				
	
			
			
			
						parent
						
							23a779bf3d
						
					
				
				
					commit
					2986a524d8
				
			| @@ -421,14 +421,6 @@ frok::parent (volatile char * volatile stack_here) | |||||||
|       this_errno = EAGAIN; |       this_errno = EAGAIN; | ||||||
| #ifdef DEBUGGING0 | #ifdef DEBUGGING0 | ||||||
|       error ("child remember failed"); |       error ("child remember failed"); | ||||||
| #endif |  | ||||||
|       goto cleanup; |  | ||||||
|     } |  | ||||||
|   if (!child.reattach ()) |  | ||||||
|     { |  | ||||||
|       this_errno = EAGAIN; |  | ||||||
| #ifdef DEBUGGING0 |  | ||||||
|       error ("child reattach failed"); |  | ||||||
| #endif | #endif | ||||||
|       goto cleanup; |       goto cleanup; | ||||||
|     } |     } | ||||||
| @@ -516,6 +508,17 @@ frok::parent (volatile char * volatile stack_here) | |||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |   /* Do not attach to the child before it has successfully initialized. | ||||||
|  |      Otherwise we may wait forever, or deliver an orphan SIGCHILD. */ | ||||||
|  |   if (!child.reattach ()) | ||||||
|  |     { | ||||||
|  |       this_errno = EAGAIN; | ||||||
|  | #ifdef DEBUGGING0 | ||||||
|  |       error ("child reattach failed"); | ||||||
|  | #endif | ||||||
|  |       goto cleanup; | ||||||
|  |     } | ||||||
|  |  | ||||||
|   /* Finally start the child up. */ |   /* Finally start the child up. */ | ||||||
|   resume_child (forker_finished); |   resume_child (forker_finished); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user