Browse Source

Actually, it's probably safer *not* to leave child processes hanging

around which still hold pointers to variables belonging to our parent...
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
d6909f65f0
1 changed files with 8 additions and 9 deletions
  1. 8
    9
      src/core/resolv.c

+ 8
- 9
src/core/resolv.c View File

106
 	/* Reap the child */
106
 	/* Reap the child */
107
 	async_wait ( async, &rc, 1 );
107
 	async_wait ( async, &rc, 1 );
108
 
108
 
109
-	/* If this child succeeded, kill all the others and return.
110
-	 * Killing the others means that this routine may be
111
-	 * re-entered; this is safe provided that no child returns a
112
-	 * success exit status when killed by SIGKILL.
109
+	/* If this child succeeded, kill all the others.  They should
110
+	 * immediately die (invoking resolv_sigchld() again, which
111
+	 * won't do anything because the exit status is non-zero and
112
+	 * the pending count won't reach zero until this instance
113
+	 * completes).
113
 	 */
114
 	 */
114
-	if ( rc == 0 ) {
115
+	if ( rc == 0 )
115
 		async_signal_children ( async, SIGKILL );
116
 		async_signal_children ( async, SIGKILL );
116
-		async_done ( async, 0 );
117
-		return;
118
-	}
119
 
117
 
120
-	/* If we have no children left, return failure */
118
+	/* When we have no children left, exit */
121
 	if ( --(resolution->pending) == 0 )
119
 	if ( --(resolution->pending) == 0 )
122
 		async_done ( async, rc );
120
 		async_done ( async, rc );
123
 }
121
 }
135
 static struct async_operations resolv_async_operations = {
133
 static struct async_operations resolv_async_operations = {
136
 	.reap = resolv_reap,
134
 	.reap = resolv_reap,
137
 	.signal = {
135
 	.signal = {
136
+		[SIGKILL] = async_signal_children,
138
 		[SIGCHLD] = resolv_sigchld,
137
 		[SIGCHLD] = resolv_sigchld,
139
 	},
138
 	},
140
 };
139
 };

Loading…
Cancel
Save