=================================================================== RCS file: /home/cvs/OpenXM/src/kxx/oxmain.c,v retrieving revision 1.19 retrieving revision 1.21 diff -u -p -r1.19 -r1.21 --- OpenXM/src/kxx/oxmain.c 2004/09/17 08:46:10 1.19 +++ OpenXM/src/kxx/oxmain.c 2005/02/28 12:53:44 1.21 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.18 2004/09/17 07:27:28 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.20 2004/09/17 12:32:11 takayama Exp $ */ /* nullserver01 */ #include #include @@ -37,6 +37,7 @@ static void errorToStartEngine(void); static int findOxServer(char *server); static void couldNotFind(char *s); /* gcc -v -c hoge.c */ +static void mywait(); void *sGC_malloc(int n) { return (void *)malloc(n); @@ -157,6 +158,11 @@ main(int argc, char *argv[]) { result = 0; + if ((fdControl < 0) || (fdStream < 0)) { + fprintf(stderr,"Waiting for 10 seconds to show an error.\n"); + sleep(10); + } + if (portControl != -1) { MyServerPid = fork(); if (MyServerPid > 0 ) parentServerMain(fdControl,fdStream); @@ -249,6 +255,12 @@ main(int argc, char *argv[]) { free(s); } + if ((fdControl < 0) || (fdStream < 0)) { + fprintf(stderr,"Waiting for 10 seconds to show an error.\n"); + sleep(10); + } + + result = 0; if (portControl != -1) { MyServerPid = fork(); @@ -269,7 +281,7 @@ static void errorToStartEngine(void) { If you implement this, set Do_not_use_control_stream_to_tell_no_server to zero. */ - sleep(2); + sleep(10); exit(-1); } @@ -315,6 +327,7 @@ parentServerMain(int fdControl, int fdStream) { extern OxTerminateMode; extern void myServerExit(); + signal(SIGCHLD,mywait); if (OxTerminateMode) { /* OxTerminateMode cannot be used if you run ox by xterm -exec ox ... @@ -471,5 +484,16 @@ static void couldNotFind(char *s) { } +static void mywait() { + int status; + int pid; + int i,j; + /* signal(SIGCHLD,SIG_IGN); */ + pid = wait(&status); + fprintf(stderr,"Control: child process %d is exiting.\n",pid); + fprintf(stderr,"Control: Shutting down the control server.\n"); + sleep(2); + exit(0); +}