[Opensrf-commits] r1087 - trunk/src/libopensrf
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Aug 27 20:35:01 EDT 2007
Author: miker
Date: 2007-08-27 20:29:22 -0400 (Mon, 27 Aug 2007)
New Revision: 1087
Modified:
trunk/src/libopensrf/osrf_system.c
Log:
patch from Scott McKellar to examine and report the exit status of child processes as they shut down
Modified: trunk/src/libopensrf/osrf_system.c
===================================================================
--- trunk/src/libopensrf/osrf_system.c 2007-08-28 00:28:22 UTC (rev 1086)
+++ trunk/src/libopensrf/osrf_system.c 2007-08-28 00:29:22 UTC (rev 1087)
@@ -4,6 +4,7 @@
#include <signal.h>
static int _osrfSystemInitCache( void );
+static void report_child_status( pid_t pid, int status );
static transport_client* osrfGlobalTransportClient = NULL;
@@ -140,7 +141,8 @@
while(1) {
errno = 0;
- pid_t pid = wait(NULL);
+ int status;
+ pid_t pid = wait( &status );
if(-1 == pid) {
if(errno == ECHILD)
osrfLogError(OSRF_LOG_MARK, "We have no more live services... exiting");
@@ -148,13 +150,38 @@
osrfLogError(OSRF_LOG_MARK, "Exiting top-level system loop with error: %s", strerror(errno));
break;
} else {
- osrfLogError(OSRF_LOG_MARK, "We lost a top-level service process with PID %ld", pid);
+ report_child_status( pid, status );
}
}
return 0;
}
+
+static void report_child_status( pid_t pid, int status ) {
+
+ if( WIFEXITED( status ) )
+ {
+ int rc = WEXITSTATUS( status ); // return code of child process
+ if( rc )
+ osrfLogError( OSRF_LOG_MARK, "Child process %ld exited with return code %d",
+ (long) pid, rc );
+ else
+ osrfLogError( OSRF_LOG_MARK, "Child process %ld exited normally", (long) pid );
+ }
+ else if( WIFSIGNALED( status ) )
+ {
+ osrfLogError( OSRF_LOG_MARK, "Child process %ld killed by signal %d",
+ (long) pid, WTERMSIG( status) );
+ }
+ else if( WIFSTOPPED( status ) )
+ {
+ osrfLogError( OSRF_LOG_MARK, "Child process %ld stopped by signal %d",
+ (long) pid, (int) WSTOPSIG( status ) );
+ }
+}
+
+
int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, char* resource ) {
int failure = 0;
More information about the opensrf-commits
mailing list