From 7984e9ac2079c3785a989eaec46ebdcf70da50e9 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 29 May 2007 03:03:44 +0000 Subject: [PATCH] Change suggested by Scott McKellar; handle c-app children death without a signal handler. http://list.georgialibraries.org/pipermail/open-ils-dev/2007-May/000955.html git-svn-id: svn://svn.open-ils.org/ILS/trunk@7376 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- OpenSRF/src/libstack/osrf_system.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/OpenSRF/src/libstack/osrf_system.c b/OpenSRF/src/libstack/osrf_system.c index bc5d148e3e..a9f793eff5 100644 --- a/OpenSRF/src/libstack/osrf_system.c +++ b/OpenSRF/src/libstack/osrf_system.c @@ -118,7 +118,7 @@ int osrfSystemBootstrap( char* hostname, char* configfile, char* contextNode ) { if( osrfAppRegisterApplication( appname, libfile ) == 0 ) osrf_prefork_run(appname); - osrfLogDebug( OSRF_LOG_MARK, "Server exiting for app %s and library %s", appname, libfile ); + osrfLogDebug( OSRF_LOG_MARK, "Server exiting for app %s and library %s\n", appname, libfile ); exit(0); } } // language == c @@ -130,10 +130,20 @@ int osrfSystemBootstrap( char* hostname, char* configfile, char* contextNode ) { /* background and let our children do their thing */ daemonize(); while(1) { - signal(SIGCHLD, osrfSystemSignalHandler); - sleep(10000); + errno = 0; + pid_t pid = wait( NULL ); + if ( -1 == pid ) { + if ( errno != ECHILD ) { + char* err_str = strerror( errno ); + osrfLogWarning( OSRF_LOG_MARK, "Exiting on singal or error: %s\n", err_str ); + free(err_str); + } + break; + } else { + osrfLogWarning( OSRF_LOG_MARK, "We lost child %d", pid); + } } - + return 0; } -- 2.11.0