]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/manager/ortemanager.c
Fix reported problem "compile error on cygwin"
[orte.git] / orte / manager / ortemanager.c
index 142468626b5aea0866ffc7d0f96fc35d721579b9..c6c29a34a79ec27d7c505867ae91472749dca533 100644 (file)
@@ -12,7 +12,7 @@
  *                      http://dce.felk.cvut.cz                       
  *                      http://www.ocera.org                          
  *                                                                    
- *  Author:             Petr Smolik    petr.smolik@wo.cz             
+ *  Author:             Petr Smolik    petr@smoliku.cz             
  *  Advisor:            Pavel Pisa                                   
  *  Project Responsible: Zdenek Hanzalek                              
  *  --------------------------------------------------------------------
  
 #include "orte_all.h"
 
+#ifdef HAVE_INTTYPES_H
+ #include <inttypes.h>
+ #if defined(PRIx32) && !defined(ORTE_PRI_HostId)
+  #define ORTE_PRI_HostId PRIx32
+  #define ORTE_PRI_AppId PRIx32
+ #endif
+#endif /*HAVE_INTTYPES_H*/
+
+#ifndef ORTE_PRI_HostId
+  #define ORTE_PRI_HostId x
+  #define ORTE_PRI_AppId x
+#endif
+
+#ifdef MAIN_RENAMED
+#define main ortemanager_main
+#define exit return
+#endif
+
 #ifndef CONFIG_ORTE_RT
 //global variables
-ORTEDomain          *d;
-ORTEDomainProp      dp;
-int32_t             opt,domain=ORTE_DEFAULT_DOMAIN;
-Boolean             orteDaemon=ORTE_FALSE;
-Boolean             orteWinService=ORTE_FALSE;
-ORTEDomainAppEvents *events=NULL;
+static ORTEDomain          *d;
+static ORTEDomainProp      dp;
+static int32_t             opt,domain=ORTE_DEFAULT_DOMAIN;
+static Boolean             orteDaemon=ORTE_FALSE;
+static Boolean             orteWinService=ORTE_FALSE;
+static ORTEDomainAppEvents *events=NULL;
 
 //event system
 Boolean
 onMgrAppRemoteNew(const struct ORTEAppInfo *appInfo, void *param) {
-  printf("%s 0x%x-0x%x was accepted\n",
+  printf("%s 0x%"ORTE_PRI_HostId"-0x%"ORTE_PRI_AppId" was accepted\n",
          (appInfo->appId & 0x3)==MANAGER ? "manager" : "application",
          appInfo->hostId,appInfo->appId);
   return ORTE_TRUE;
@@ -51,12 +69,12 @@ onMgrAppRemoteNew(const struct ORTEAppInfo *appInfo, void *param) {
 
 void
 onMgrAppDelete(const struct ORTEAppInfo *appInfo, void *param) {
-  printf("%s 0x%x-0x%x was deleted\n",
+  printf("%s 0x%"ORTE_PRI_HostId"-0x%"ORTE_PRI_AppId" was deleted\n",
          (appInfo->appId & 0x3)==MANAGER ? "manager" : "application",
          appInfo->hostId,appInfo->appId);
 }
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
 //Windows service support
 void serviceDispatchTable(void);  //forward declaration
 void removeService(void);         //forward declaration
@@ -77,13 +95,23 @@ int managerStop(void) {
 #endif
 
 #ifdef CONFIG_ORTE_UNIX
+#ifdef HAVE_SYS_STAT_H
+  #include <sys/stat.h>                /* For umask() */
+#endif
 //Unix daemon support
 void waitForEndingCommand(void) {
        sigset_t sigset;
        sigemptyset(&sigset);
        sigaddset(&sigset, SIGINT);
        sigaddset(&sigset, SIGTERM);
-       sigwaitinfo(&sigset, NULL);
+       {
+       #ifdef HAVE_SIGWAITINFO
+               sigwaitinfo(&sigset, NULL);
+       #else /*HAVE_SIGWAITINFO*/
+               int sig;
+               sigwait(&sigset, &sig);
+       #endif /*HAVE_SIGWAITINFO*/
+       }
 }
 static int daemonInit(void) {
   pid_t pid;
@@ -124,7 +152,7 @@ static void usage(void) {
   printf("  -e, --events                  register event system\n");
   printf("  -l, --logfile <filename>      set log file name\n");
   printf("  -V, --version                 show version\n");
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
   printf("  -i, --install_service         install service into service manager on Windows\n");
   printf("  -r, --remove_service          remove service from service manager on Windows\n");
 #endif
@@ -215,7 +243,7 @@ int main(int argc,char *argv[]) {
       case 'D':
         orteDaemon=ORTE_TRUE;
         break;
-      #ifdef _WIN32
+      #if defined(_WIN32) || defined(__CYGWIN__)
       case 's':
         serviceDispatchTable();
         exit(0);