]> rtime.felk.cvut.cz Git - orte.git/blobdiff - orte/manager/ortemanager.c
Merge branch 'master' of ssh://git@rtime.felk.cvut.cz/orte into android
[orte.git] / orte / manager / ortemanager.c
index 4b9bfb5d6c5a3846e5d021b68a4c8a7a68aa1ad4..5e198bc5a87dd435bff60ded753f7bed1fa8e489 100644 (file)
@@ -2,9 +2,19 @@
  *  $Id: ortemanager.c,v 0.0.0.1        2003/10/07
  *
  *  DEBUG:  section                     Manager
- *  AUTHOR: Petr Smolik                 petr.smolik@wo.cz
  *
- *  ORTE - OCERA Real-Time Ethernet     http://www.ocera.org/
+ *  -------------------------------------------------------------------  
+ *                                ORTE                                 
+ *                      Open Real-Time Ethernet                       
+ *                                                                    
+ *                      Copyright (C) 2001-2006                       
+ *  Department of Control Engineering FEE CTU Prague, Czech Republic  
+ *                      http://dce.felk.cvut.cz                       
+ *                      http://www.ocera.org                          
+ *                                                                    
+ *  Author:             Petr Smolik    petr.smolik@wo.cz             
+ *  Advisor:            Pavel Pisa                                   
+ *  Project Responsible: Zdenek Hanzalek                              
  *  --------------------------------------------------------------------
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -20,6 +30,7 @@
  */
  
 #include "orte_all.h"
+#include <sys/stat.h>
 
 #ifndef CONFIG_ORTE_RT
 //global variables
@@ -67,30 +78,17 @@ int managerStop(void) {
 #endif
 
 #ifdef CONFIG_ORTE_UNIX
+#ifdef HAVE_SYS_STAT_H
+  #include <sys/stat.h>                /* For umask() */
+#endif
 //Unix daemon support
-pthread_mutex_t     mutex; //for wake up
-pthread_cond_t     cond; //for wake up
-int                cvalue;
-void sig_usr(int signo) {
-  if ((signo==SIGTERM) || (signo==SIGINT)) {
-    pthread_mutex_lock(&mutex);
-    cvalue=1;
-    pthread_cond_signal(&cond);
-    pthread_mutex_unlock(&mutex);
-  }
-}
 void waitForEndingCommand(void) {
-  pthread_mutex_init(&mutex, NULL);
-  pthread_cond_init(&cond, NULL);
-  cvalue=0;
-  signal(SIGTERM,sig_usr);
-  signal(SIGINT,sig_usr);
-  pthread_mutex_lock(&mutex);
-  while(cvalue==0)
-    pthread_cond_wait(&cond,&mutex);
-  pthread_mutex_unlock(&mutex);
-  pthread_mutex_destroy(&mutex);
-  pthread_cond_destroy(&cond);
+       sigset_t sigset;
+       int sig;
+       sigemptyset(&sigset);
+       sigaddset(&sigset, SIGINT);
+       sigaddset(&sigset, SIGTERM);
+       sigwait(&sigset, &sig);
 }
 static int daemonInit(void) {
   pid_t pid;
@@ -123,6 +121,7 @@ static void usage(void) {
   printf("  -P, --purge <s>               purge time in second(s)\n");
   printf("  -I, --metaMulticast <IPAdd>   use multicast IPAddr for metatraffic comm.\n");
   printf("  -t, --timetolive <number>     time-to-live for multicast packets\n");
+  printf("  -L, --listen <IPAdd>          IP address to listen on\n");
 #ifdef CONFIG_ORTE_UNIX
   printf("  -D, --daemon                  start program like daemon\n");
 #endif
@@ -148,6 +147,7 @@ int main(int argc,char *argv[]) {
     { "purge",1,0, 'P' },
     { "metaMulticast",1,0, 'I' },
     { "timetolive",1,0, 't' },
+    { "listen",1,0, 'L' },
 #ifdef CONFIG_ORTE_UNIX
     { "daemon",1,0, 'D' },
 #endif
@@ -166,9 +166,9 @@ int main(int argc,char *argv[]) {
   ORTEDomainPropDefaultGet(&dp);
 
 #if defined HAVE_GETOPT_LONG || defined HAVE_GETOPT_LONG_ORTE
-  while ((opt = getopt_long(argc, argv, "k:p:d:v:R:E:P:I:t:l:VhDesir",&long_opts[0], NULL)) != EOF) {
+  while ((opt = getopt_long(argc, argv, "k:p:d:v:R:E:P:I:t:L:l:VhDesir",&long_opts[0], NULL)) != EOF) {
 #else
-  while ((opt = getopt(argc, argv, "k:p:d:v:R:E:P:I:t:l:VhDesir")) != EOF) {
+  while ((opt = getopt(argc, argv, "k:p:d:v:R:E:P:I:t:L:l:VhDesir")) != EOF) {
 #endif
     switch (opt) {
       case 'p':
@@ -193,6 +193,9 @@ int main(int argc,char *argv[]) {
         dp.multicast.enabled=ORTE_TRUE;
         dp.multicast.ipAddress=StringToIPAddress(optarg);
         break;
+      case 'L':
+        dp.listen=StringToIPAddress(optarg);
+        break;
       case 't':
         dp.multicast.ttl=strtol(optarg,NULL,0);
         break;
@@ -211,7 +214,7 @@ int main(int argc,char *argv[]) {
         ORTEVerbositySetLogFile(optarg);
         break;
       case 'V':
-        printf("Ocera Real-Time Ethernet (%s).\n",dp.version);
+        printf("Open Real-Time Ethernet (%s).\n",dp.version);
         exit(0);
         break;
       case 'D':
@@ -243,8 +246,10 @@ int main(int argc,char *argv[]) {
   }
   
   d=ORTEDomainMgrCreate(domain,&dp,events,ORTE_TRUE);
-  if (!d)
+  if (!d) {
+    perror("ORTEDomainMgrCreate");
     exit(1);
+  }
 
   #ifdef CONFIG_ORTE_UNIX
   if (orteDaemon)