From 12af43f837748f0de54c0bbd3fb1f05d50e187ed 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/OpenSRF/trunk@923 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libstack/osrf_system.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libstack/osrf_system.c b/src/libstack/osrf_system.c index bc5d148..a9f793e 100644 --- a/src/libstack/osrf_system.c +++ b/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