Oops, forgot the attachment...
Scott McKellar
http://home.swbell.net/mck9/ct/
*** trunk/src/libopensrf/osrf_system.c 2007-08-14 21:40:18.000000000 -0500
--- trunk-mod/src/libopensrf/osrf_system.c 2007-08-14 21:51:43.000000000 -0500
***************
*** 4,9 ****
--- 4,10 ----
#include <signal.h>
static int _osrfSystemInitCache( void );
+ static void report_child_status( pid_t pid, int status );
static transport_client* osrfGlobalTransportClient = NULL;
***************
*** 140,146 ****
while(1) {
errno = 0;
! pid_t pid = wait(NULL);
if(-1 == pid) {
if(errno == ECHILD)
osrfLogError(OSRF_LOG_MARK, "We have no more live services... exiting");
--- 141,148 ----
while(1) {
errno = 0;
! 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,160 ****
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);
}
}
return 0;
}
int osrf_system_bootstrap_client_resc( char* config_file, char* contextnode, char* resource ) {
int failure = 0;
--- 150,187 ----
osrfLogError(OSRF_LOG_MARK, "Exiting top-level system loop with error: %s", strerror(errno));
break;
} else {
! 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;