Don't respawn if child died in less than a second.

This commit is contained in:
ehouse 2007-12-05 06:30:45 +00:00
parent c2ad749f99
commit 3013b89b03

View file

@ -631,8 +631,14 @@ int main( int argc, char** argv )
} else if ( pid > 0 ) {
int status;
logf( XW_LOGINFO, "parent waiting on child pid=%d", pid );
time_t time_before = time( NULL );
waitpid( pid, &status, 0 );
printWhy( status );
time_t time_after = time( NULL );
doFork = time_after > time_before;
if ( !doFork ) {
logf( XW_LOGERROR, "exiting b/c respawned too quickly" );
}
} else {
logf( XW_LOGERROR, "fork() => %s", strerror(errno) );
}