@@ -209,7 +209,7 @@ ACL_VSTREAM *acl_vstream_popen(int flags,...)
209209 if (close (sockfd [0 ]))
210210 acl_msg_warn ("close: %s" , acl_last_serror ());
211211 fp = acl_vstream_fdopen (sockfd [1 ], flags ,
212- 4096 , 0 , ACL_VSTREAM_TYPE_FILE );
212+ 4096 , 0 , ACL_VSTREAM_TYPE_SOCK );
213213 /*
214214 * fp->waitpid_fn = args.waitpid_fn;
215215 */
@@ -233,23 +233,31 @@ int acl_vstream_pclose(ACL_VSTREAM *fp)
233233 /*
234234 * Close the pipe. Don't trigger an alarm in vstream_fclose().
235235 */
236- if (saved_pid == 0 )
236+ if (saved_pid == 0 ) {
237237 acl_msg_panic ("vstream_pclose: fp has no process" );
238+ }
239+
240+ if (fp -> errnum == ACL_ETIMEDOUT ) {
241+ acl_msg_warn ("kill child(%d) for waiting timeout " , saved_pid );
242+ kill (saved_pid , SIGTERM );
243+ }
244+
238245 fp -> pid = 0 ;
239246 acl_vstream_fclose (fp );
240247
241248 /*
242249 * Reap the child exit status.
243250 */
244251 do {
245- if (saved_waitpid_fn != 0 )
252+ if (saved_waitpid_fn != 0 ) {
246253 pid = saved_waitpid_fn (saved_pid , & wait_status , 0 );
247- else
254+ } else {
248255 pid = waitpid (saved_pid , & wait_status , 0 );
256+ }
249257 } while (pid == -1 && errno == EINTR );
250- return pid == -1 ? -1 :
251- WIFSIGNALED ( wait_status ) ? WTERMSIG (wait_status ) :
252- WEXITSTATUS (wait_status );
258+
259+ return pid == -1 ? -1 : WIFSIGNALED (wait_status ) ?
260+ WTERMSIG ( wait_status ) : WEXITSTATUS (wait_status );
253261}
254262
255263#elif defined(ACL_WINDOWS )
0 commit comments