Salome HOME
A little fix for compilation on old gcc (i.e. 3.3.5)
[tools/libbatch.git] / src / Local / Batch_BatchManager_Local.cxx
index 1f95608d1fdc1460efa6979731c375c6b3607590..fd975fe3125b24f593ae4e16e54b91087e92883d 100644 (file)
@@ -62,7 +62,6 @@ namespace Batch {
   // Constructeur
   BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host,
                                          CommunicationProtocolType protocolType)
-      throw(InvalidArgumentException,ConnexionFailureException)
     : BatchManager(parent, host), _connect(0), _threads_mutex(), _threads(),
       _protocol(CommunicationProtocol::getInstance(protocolType)),
       _thread_id_id_association_mutex(), _thread_id_id_association_cond(), _thread_id_id_association()
@@ -444,6 +443,9 @@ namespace Batch {
         string local    = cp.getLocal();
         string remote   = cp.getRemote();
 
+       std::cerr << workdir << std::endl;
+       std::cerr << remote << std::endl;
+
         int status = p_ta->getBatchManager().getProtocol().copyFile(local, "", "",
                                                                     workdir + "/" + remote,
                                                                     executionhost, user);
@@ -464,6 +466,8 @@ namespace Batch {
     // On forke/exec un nouveau process pour pouvoir controler le fils
     // (plus finement qu'avec un appel system)
     // int rc = system(commande.c_str());
+    //char *const parmList[] = {"/usr/bin/ssh", "localhost", "-l", "aribes", "sleep 10 && echo end", NULL};
+    //execv("/usr/bin/ssh", parmList);
 #ifdef WIN32
     child = p_ta->launchWin32ChildProcess();
     p_ta->pere(child);
@@ -595,6 +599,16 @@ namespace Batch {
       int child_rc = 0;
       pid_t child_wait_rc = waitpid(child, &child_rc, WNOHANG /* | WUNTRACED */);
       if (child_wait_rc > 0) {
+        UNDER_LOCK( cout << "Status is: " << WIFEXITED( child_rc) << endl);
+        UNDER_LOCK( cout << "Status is: " << WEXITSTATUS( child_rc) << endl);
+        UNDER_LOCK( cout << "Status is: " << WIFSIGNALED( child_rc) << endl);
+        UNDER_LOCK( cout << "Status is: " << WTERMSIG( child_rc) << endl);
+        UNDER_LOCK( cout << "Status is: " << WCOREDUMP( child_rc) << endl);
+        UNDER_LOCK( cout << "Status is: " << WIFSTOPPED( child_rc) << endl);
+        UNDER_LOCK( cout << "Status is: " << WSTOPSIG( child_rc) << endl);
+#ifdef WIFCONTINUED
+        UNDER_LOCK( cout << "Status is: " << WIFCONTINUED( child_rc) << endl); // not compilable on sarge
+#endif
         if (WIFSTOPPED(child_rc)) {
           // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED
           // soit positionne dans l'appel a waitpid ci-dessus. Ce flag est couramment
@@ -741,6 +755,10 @@ namespace Batch {
     Parametre param = _job.getParametre();
     Parametre::iterator it;
 
+      //char *const parmList[] = {"/usr/bin/ssh", "localhost", "-l", "aribes", "sleep 1 && echo end", NULL};
+      //int result = execv("/usr/bin/ssh", parmList);
+      //UNDER_LOCK( cout << "*** debug_command = " << result << endl );
+      //UNDER_LOCK( cout << "*** debug_command = " << strerror(errno) << endl );
     try {
 
       // EXECUTABLE is MANDATORY, if missing, we exit with failure notification
@@ -762,6 +780,7 @@ namespace Batch {
       argv[command.size()] = NULL;
 
       UNDER_LOCK( cout << "*** debug_command = " << comstr << endl );
+      UNDER_LOCK( cout << "*** debug_command = " << argv[0] << endl );
 
       // Create the environment for the new process. Note (RB): Here we change the environment for
       // the process launched in local. It would seem more logical to set the environment for the
@@ -785,6 +804,10 @@ namespace Batch {
         envp[i] = NULL;
       }
 
+      //char *const parmList[] = {"/usr/bin/ssh", "localhost", "-l", "aribes", "sleep 1 && echo end", NULL};
+      //int result = execv("/usr/bin/ssh", parmList);
+      //UNDER_LOCK( cout << "*** debug_command = " << result << endl );
+      //UNDER_LOCK( cout << "*** debug_command = " << strerror(errno) << endl );
 
 
 
@@ -814,6 +837,10 @@ namespace Batch {
       }
 
 
+      //char *const parmList[] = {"/usr/bin/ssh", "localhost", "-l", "aribes", "sleep 1 && echo end", NULL};
+      //int result = execv("/usr/bin/ssh", parmList);
+      //UNDER_LOCK( cout << "*** debug_command = " << result << endl );
+      //UNDER_LOCK( cout << "*** debug_command = " << strerror(errno) << endl );
 
       // On cree une session pour le fils de facon a ce qu'il ne soit pas
       // detruit lorsque le shell se termine (le shell ouvre une session et
@@ -828,8 +855,8 @@ namespace Batch {
 
 
       // On execute la commande du fils
-      execve(argv[0], argv, envp);
-
+      int result = execve(argv[0], argv, envp);
+      UNDER_LOCK( cout << "*** debug_command = " << strerror(errno) << endl );
       // No need to deallocate since nothing happens after a successful exec
 
       // Normalement on ne devrait jamais arriver ici