]> 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 4cd4d13277dbc71aaf35a414007777d4972c9386..5e198bc5a87dd435bff60ded753f7bed1fa8e489 100644 (file)
@@ -30,6 +30,7 @@
  */
  
 #include "orte_all.h"
+#include <sys/stat.h>
 
 #ifndef CONFIG_ORTE_RT
 //global variables
@@ -77,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;