[BACK]Return to oxmain.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kxx

Diff for /OpenXM/src/kxx/oxmain.c between version 1.24 and 1.28

version 1.24, 2006/06/05 00:25:50 version 1.28, 2016/08/27 00:11:27
Line 1 
Line 1 
 /*  $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.23 2006/02/25 09:11:10 takayama Exp $  */  /*  $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.27 2016/03/30 21:34:03 takayama Exp $  */
   /*  Note on IntelMac. [2006.06.05]
       SIGINT does not seem to be blocked on the rosetta emulator of ppc
       on the IntelMac's. "ox" should be universal binary.
      A dirty hack to generate a universal binary of ox is as follows.
      (1) Add -arch ppc -arch i386 to CFLAGS in src/kxx/Makefile
          and src/kan96xx/plugin/Makefile
      (2) Build ox
   */
 /* nullserver01 */  /* nullserver01 */
 #include <stdio.h>  #include <stdio.h>
 #include <fcntl.h>  #include <fcntl.h>
Line 35  int LocalMode = 1;
Line 43  int LocalMode = 1;
 int NotifyPortnumber = 0;  int NotifyPortnumber = 0;
 int Do_not_use_control_stream_to_tell_no_server = 1;  int Do_not_use_control_stream_to_tell_no_server = 1;
 int IgnoreSIGINT = 1;  int IgnoreSIGINT = 1;
   int Ox_protocol_1999 = 0;
 static void errorToStartEngine(void);  static void errorToStartEngine(void);
 static int findOxServer(char *server);  static int findOxServer(char *server);
 static void couldNotFind(char *s);  static void couldNotFind(char *s);
 /*  gcc -v -c hoge.c */  /*  gcc -v -c hoge.c */
 static void mywait();  static void mywait(int m);
   
 void *sGC_malloc(int n) {  void *sGC_malloc(int n) {
   return (void *)malloc(n);    return (void *)malloc(n);
Line 67  main(int argc, char *argv[]) {
Line 76  main(int argc, char *argv[]) {
   char *stmp;    char *stmp;
   extern int OxTerminateMode;    extern int OxTerminateMode;
   
   signal(SIGHUP,SIG_IGN);  /* ignore x of xterm */    int sighup[]={SIGHUP,-1};
     block_signal(sighup);  /* ignore x of xterm */
   strcpy(sname,"localhost");    strcpy(sname,"localhost");
   strcpy(ServerName,SERVERNAME);    strcpy(ServerName,SERVERNAME);
   i = 1;    i = 1;
Line 135  main(int argc, char *argv[]) {
Line 145  main(int argc, char *argv[]) {
     }else if (strcmp(argv[i],"-ignoreSIGINT") == 0) {      }else if (strcmp(argv[i],"-ignoreSIGINT") == 0) {
       i++;        i++;
       if (i<argc) {        if (i<argc) {
         IgnoreSIGINT = argv[i];          sscanf(argv[i],"%d",&IgnoreSIGINT);
       }        }
       }else if (strcmp(argv[i],"-protocol_1999") == 0) {
         Ox_protocol_1999=1;
     }else {      }else {
       fprintf(stderr,"Unknown option %s.\n",argv[i]);        fprintf(stderr,"Unknown option %s.\n",argv[i]);
       oxmainUsage(); exit(10);        oxmainUsage(); exit(10);
Line 359  parentServerMain(int fdControl, int fdStream) {
Line 371  parentServerMain(int fdControl, int fdStream) {
   int message = 1;    int message = 1;
   int controlByteOrder;    int controlByteOrder;
   extern OxTerminateMode;    extern OxTerminateMode;
   extern void myServerExit();    extern void myServerExit(int m);
   
   signal(SIGCHLD,mywait);    int sigchld[]={SIGCHLD,-1};
     unblock_signal(sigchld);
   if (OxTerminateMode) {    if (OxTerminateMode) {
         /*          /*
           OxTerminateMode cannot be used if you run ox by xterm -exec ox ...            OxTerminateMode cannot be used if you run ox by xterm -exec ox ...
Line 377  parentServerMain(int fdControl, int fdStream) {
Line 390  parentServerMain(int fdControl, int fdStream) {
   /* Set the network byte order. */    /* Set the network byte order. */
   fprintf(stderr,"controlByteOrder=%x\n",controlByteOrder);    fprintf(stderr,"controlByteOrder=%x\n",controlByteOrder);
   
     int sigint[]={SIGINT,-1};
   signal(SIGINT,myServerExit);    set_signal(sigint[0],myServerExit);
     unblock_signal(sigint);
   while(1) {    while(1) {
     mtag = oxfdGetOXheader(fdControl,&SerialCurrentControl);      mtag = oxfdGetOXheader(fdControl,&SerialCurrentControl);
     /* get the message_tag */      /* get the message_tag */
Line 388  parentServerMain(int fdControl, int fdStream) {
Line 402  parentServerMain(int fdControl, int fdStream) {
     switch( id ) {      switch( id ) {
     case SM_control_kill:      case SM_control_kill:
       if (message) printf("[control] control_kill\n");        if (message) printf("[control] control_kill\n");
       oxSendResultOfControl(fdControl);        /* oxSendResultOfControl(fdControl); */
       sleep(2);        sleep(2);
       myServerExit();        myServerExit(0);
       break;        break;
     case SM_control_reset_connection:      case SM_control_reset_connection:
       if (message) printf("[control] control_reset_connection.\n");        if (message) printf("[control] control_reset_connection.\n");
       if (message) printf("Sending the SIGUSR1 signal to %d:  ",MyServerPid);        if (message) printf("Sending the SIGUSR1 signal to %d:  ",MyServerPid);
       r=kill(MyServerPid,SIGUSR1);        r=kill(MyServerPid,SIGUSR1);
       if (message) printf("Result = %d\n",r);        if (message) printf("Result = %d\n",r);
         if (Ox_protocol_1999) {
           if (message) printf("[obsolete protocol of ox-rfc-100 in 1999] Sending the result packet to the control channel.\n",r);
           oxSendResultOfControlInt32(fdControl,0);
         }
       fflush(NULL);        fflush(NULL);
       /*      oxSendResultOfControlInt32(fdControl,0); */        /*      oxSendResultOfControlInt32(fdControl,0); */
       break;        break;
     default:      default:
       fprintf(stderr,"[control] Unknown control message.\n");        fprintf(stderr,"[control] Unknown control message.\n");
       fprintf(stderr,"Shutdown the server.");        fprintf(stderr,"Shutdown the server.");
       myServerExit();        myServerExit(0);
       break;        break;
     }      }
   }    }
 }  }
   
 void myServerExit() {  void myServerExit(int m) {
   printf("Sending the kill signal to the child.\n");    printf("Sending the kill signal to the child.\n");
   kill(MyServerPid,SIGKILL);    kill(MyServerPid,SIGKILL);
   exit(0);    exit(0);
Line 464  childServerMain(int fdControl, int fdStream) {
Line 482  childServerMain(int fdControl, int fdStream) {
         setrlimit(RLIMIT_STACK,&res);          setrlimit(RLIMIT_STACK,&res);
   }    }
   
   if (IgnoreSIGINT) signal(SIGINT, SIG_IGN);    int sigint[]={SIGINT,-1};
     if (IgnoreSIGINT) { block_signal(sigint); fprintf(stderr,"SIGING\n");}
   
   if (PacketMonitor) {    if (PacketMonitor) {
     if (execle(ServerName,ServerName,"-monitor",NULL,environ)) {      if (execle(ServerName,ServerName,"-monitor",NULL,environ)) {
Line 527  static void couldNotFind(char *s) {
Line 546  static void couldNotFind(char *s) {
 }  }
   
   
 static void mywait() {  static void mywait(int m) {
   int status;    int status;
   int pid;    int pid;
   int i,j;    int i,j;

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.28

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>