version 1.2, 2003/07/21 11:56:33 |
version 1.8, 2016/03/31 05:27:34 |
|
|
/* $OpenXM: OpenXM/src/kxx/ox100start.c,v 1.1 2003/07/21 07:32:01 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kxx/ox100start.c,v 1.7 2006/01/26 08:36:50 takayama Exp $ */ |
/* Moved from misc-2003/07/cygwin/test.c */ |
/* Moved from misc-2003/07/cygwin/test.c */ |
#include <stdio.h> |
#include <stdio.h> |
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include <signal.h> |
#include <signal.h> |
#include <ctype.h> |
#include <ctype.h> |
#include "ox_pathfinder.h" |
#include "ox_pathfinder.h" |
|
#include "mysig.h" |
|
|
static void usage(void); |
static void usage(void); |
static int forkExec(char **argv); |
static int forkExec(char **argv); |
|
void *sGC_malloc(int size) { |
|
return ((void *)malloc(size)); |
|
} |
|
|
|
int Quiet = 0; |
|
static int EngineLogToStdout = 0; |
extern char **environ; |
extern char **environ; |
|
|
main(int argc,char *argv[]) { |
main(int argc,char *argv[]) { |
Line 26 main(int argc,char *argv[]) { |
|
Line 32 main(int argc,char *argv[]) { |
|
int i; |
int i; |
char *serverName; |
char *serverName; |
|
|
|
|
/* |
/* |
if (Verbose_get_home) { |
|
printf("ostype=%s\n",getOStypes()); |
printf("ostype=%s\n",getOStypes()); |
printf("OpenXM_HOME=%s\n",getOpenXM_HOME()); |
printf("OpenXM_HOME=%s\n",getOpenXM_HOME()); |
printf("sm lib =%s\n",get_sm1_lib_path()); |
printf("sm lib =%s\n",get_sm1_lib_path()); |
printf("k0 lib =%s\n",get_k0_lib_path()); |
printf("k0 lib =%s\n",get_k0_lib_path()); |
printf("ox_asir =%s\n",get_ox_asir_path()); |
printf("ox_asir =%s\n",get_ox_asir_path()); |
} |
|
*/ |
*/ |
|
ox_pathfinderVerbose(1); |
|
|
|
|
/* Initialize parameters */ |
/* Initialize parameters */ |
serverName = NULL; |
serverName = NULL; |
aaa = NULL; |
aaa = NULL; |
Line 54 main(int argc,char *argv[]) { |
|
Line 61 main(int argc,char *argv[]) { |
|
aaa = getServerEnv(serverName); |
aaa = getServerEnv(serverName); |
}else if (strcmp(argv[i],"-nox")==0) { |
}else if (strcmp(argv[i],"-nox")==0) { |
ox_pathfinderNoX(1); |
ox_pathfinderNoX(1); |
|
}else if (strcmp(argv[i],"-engineLogToStdout")==0) { |
|
ox_pathfinderEngineLogToStdout(1); |
|
EngineLogToStdout = 1; |
|
}else if (strcmp(argv[i],"-quiet")==0) { |
|
Quiet = 1; ox_pathfinder_quiet(); |
}else{ |
}else{ |
fprintf(stderr,"Unknown option.\n"); |
fprintf(stderr,"Unknown option.\n"); |
usage(); |
usage(); |
Line 71 static void myforkwait() { |
|
Line 83 static void myforkwait() { |
|
int status; |
int status; |
int pid; |
int pid; |
int i,j; |
int i,j; |
signal(SIGCHLD,SIG_IGN); |
mysignal(SIGCHLD,SIG_IGN); |
pid = wait(&status); |
pid = wait(&status); |
fprintf(stderr,"Child process %d is exiting.\n",pid); |
fprintf(stderr,"Child process %d is exiting.\n",pid); |
for (i=0; i<Myforkcp; i++) { |
for (i=0; i<Myforkcp; i++) { |
Line 82 static void myforkwait() { |
|
Line 94 static void myforkwait() { |
|
if (Myforkcp > 0) Myforkcp--; |
if (Myforkcp > 0) Myforkcp--; |
} |
} |
} |
} |
signal(SIGCHLD,myforkwait); |
mysignal(SIGCHLD,myforkwait); |
} |
} |
|
|
static void usage() { |
static void usage() { |
fprintf(stderr,"oxstart100 -oxserver xxx [-e args]\n"); |
fprintf(stderr,"ox100start -oxserver xxx [-e args]\n"); |
fprintf(stderr,"Examples: \n"); |
fprintf(stderr,"Examples: \n"); |
fprintf(stderr," oxstart100 -oxserver bin/ox_sm1 -e -reverse -data 3010 --control 3012 -pass 1121343432434 \n"); |
fprintf(stderr," ox100start -oxserver bin/ox_sm1 -e -reverse -data 3010 --control 3012 -pass 1121343432434 \n"); |
|
fprintf(stderr," ox100start -nox -engineLogToStdout -oxserver bin/ox_sm1 -e -data 3010 \n"); |
|
|
} |
} |
|
|
static int forkExec(char **argv) { |
static int forkExec(char **argv) { |
Line 103 static int forkExec(char **argv) { |
|
Line 117 static int forkExec(char **argv) { |
|
if (m&2) { |
if (m&2) { |
/* Do not call singal to turn around a trouble on cygwin. BUG. */ |
/* Do not call singal to turn around a trouble on cygwin. BUG. */ |
}else{ |
}else{ |
signal(SIGCHLD,myforkwait); /* to kill Zombie */ |
mysignal(SIGCHLD,myforkwait); /* to kill Zombie */ |
} |
} |
Myforkchildren[Myforkcp++] = pid; |
Myforkchildren[Myforkcp++] = pid; |
if (Myforkcp >= MYFORKCP_SIZE-1) { |
if (Myforkcp >= MYFORKCP_SIZE-1) { |
Line 118 static int forkExec(char **argv) { |
|
Line 132 static int forkExec(char **argv) { |
|
sigaddset(&sss,SIGINT); |
sigaddset(&sss,SIGINT); |
sigprocmask(SIG_BLOCK,&sss,NULL); |
sigprocmask(SIG_BLOCK,&sss,NULL); |
} |
} |
if (ox_pathfinderNoX(-1)) { |
if (ox_pathfinderNoX(-1) && (!EngineLogToStdout)) { |
FILE *null; |
FILE *null; |
null = fopen("/dev/null","wb"); |
null = fopen("/dev/null","wb"); |
dup2(fileno(null),1); |
dup2(fileno(null),1); |
dup2(fileno(null),2); |
dup2(fileno(null),2); |
} |
} |
|
|
|
/* |
|
{ |
|
int i; |
|
i = 0; |
|
fprintf(stderr,"argv-----------\n"); |
|
while (argv[i] != NULL) { |
|
fprintf(stderr,"%s ",argv[i++]); |
|
} |
|
fprintf(stderr,"\n"); |
|
i = 0; |
|
fprintf(stderr,"environ-----------\n"); |
|
while (environ[i] != NULL) { |
|
fprintf(stderr,"%s ",environ[i++]); |
|
} |
|
fprintf(stderr,"\n"); |
|
} |
|
*/ |
|
|
execve(argv[0],argv,environ); |
execve(argv[0],argv,environ); |
/* This place will never be reached unless execv fails. */ |
/* This place will never be reached unless execv fails. */ |
fprintf(stderr,"forkExec fails: "); |
fprintf(stderr,"forkExec fails: "); |