From 3013b89b038daf729e47647e951734e35d2843aa Mon Sep 17 00:00:00 2001 From: ehouse Date: Wed, 5 Dec 2007 06:30:45 +0000 Subject: [PATCH] Don't respawn if child died in less than a second. --- relay/xwrelay.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/relay/xwrelay.cpp b/relay/xwrelay.cpp index 2db028f50..62dc65d11 100644 --- a/relay/xwrelay.cpp +++ b/relay/xwrelay.cpp @@ -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) ); }