intgen_t cldmgr_join( void ) { cld_t *p = cld; cld_t *ep = cld + sizeof( cld ) / sizeof( cld[ 0 ] ); intgen_t xc = EXIT_NORMAL; lock(); for ( ; p < ep ; p++ ) { if ( p->c_state == C_EXITED ) { if ( ( intgen_t )( p->c_streamix ) >= 0 ) { stream_dead( p->c_tid ); } pthread_join( p->c_tid, NULL ); if ( p->c_exit_code != EXIT_NORMAL && xc != EXIT_FAULT ) xc = p->c_exit_code; if ( p->c_exit_code != EXIT_NORMAL ) { mlog( MLOG_DEBUG | MLOG_PROC | MLOG_NOLOCK, "child (thread %lu) requested stop: " "exit code %d (%s)\n", p->c_tid, p->c_exit_code, exit_codestring( p->c_exit_code )); } // reinit this child for reuse memset( ( void * )p, 0, sizeof( cld_t )); } } unlock(); return xc; }
void cldmgr_died( pid_t pid ) { cld_t *cldp = cldmgr_findbypid( pid ); if ( ! cldp ) { return; } cldp->c_busy = BOOL_FALSE; if ( ( intgen_t )( cldp->c_streamix ) >= 0 ) { stream_dead( pid ); } }