@@ -63,10 +63,27 @@ static void fpm_child_free(struct fpm_child_s *child) /* {{{ */
6363}
6464/* }}} */
6565
66+ static void fpm_postponed_child_free (struct fpm_event_s * ev , short which , void * arg )
67+ {
68+ struct fpm_child_s * child = (struct fpm_child_s * ) arg ;
69+
70+ if (child -> fd_stdout != -1 ) {
71+ fpm_event_del (& child -> ev_stdout );
72+ close (child -> fd_stdout );
73+ }
74+ if (child -> fd_stderr != -1 ) {
75+ fpm_event_del (& child -> ev_stderr );
76+ close (child -> fd_stderr );
77+ }
78+
79+ fpm_child_free ((struct fpm_child_s * ) child );
80+ }
81+
6682static void fpm_child_close (struct fpm_child_s * child , int in_event_loop ) /* {{{ */
6783{
6884 if (child -> fd_stdout != -1 ) {
6985 if (in_event_loop ) {
86+ child -> postponed_free = true;
7087 fpm_event_fire (& child -> ev_stdout );
7188 }
7289 if (child -> fd_stdout != -1 ) {
@@ -76,14 +93,20 @@ static void fpm_child_close(struct fpm_child_s *child, int in_event_loop) /* {{{
7693
7794 if (child -> fd_stderr != -1 ) {
7895 if (in_event_loop ) {
96+ child -> postponed_free = true;
7997 fpm_event_fire (& child -> ev_stderr );
8098 }
8199 if (child -> fd_stderr != -1 ) {
82100 close (child -> fd_stderr );
83101 }
84102 }
85103
86- fpm_child_free (child );
104+ if (in_event_loop && child -> postponed_free ) {
105+ fpm_event_set_timer (& child -> ev_free , 0 , & fpm_postponed_child_free , child );
106+ fpm_event_add (& child -> ev_free , 1000 );
107+ } else {
108+ fpm_child_free (child );
109+ }
87110}
88111/* }}} */
89112
0 commit comments