Revision: 7855
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7855&view=rev
Author:   robotos
Date:     2009-06-18 11:26:06 +0000 (Thu, 18 Jun 2009)

Log Message:
-----------
errors when a previous gazebo crashed more self explained

Modified Paths:
--------------
    code/gazebo/trunk/libgazebo/Server.cc

Modified: code/gazebo/trunk/libgazebo/Server.cc
===================================================================
--- code/gazebo/trunk/libgazebo/Server.cc       2009-06-18 06:40:56 UTC (rev 
7854)
+++ code/gazebo/trunk/libgazebo/Server.cc       2009-06-18 11:26:06 UTC (rev 
7855)
@@ -105,32 +105,37 @@
     FILE *fp = fopen(pidfn.c_str(), "r");
     if(fp) 
     {
-      int pid;
-      if (fscanf(fp, "%d", &pid) != 0)
-        std::cerr << "Error in libgazebo Server.\n";
-
+      int pid = 0;
+      fscanf(fp, "%d", &pid);
       fclose(fp);
-      std::cout << "found a pid file: pid=" << pid << "\n";
-
-      if(kill(pid, 0) == 0) 
+      
+      if (pid != 0)
       {
-        // a gazebo process is still alive.
-        errStream << "directory [" <<  this->filename
-          <<  "] already exists (previous crash?)\n"
-          << "gazebo (pid=" << pid << ") is still running.";
-        throw(errStream.str());
-      } 
-      else 
-      {
-        // the gazebo process is not alive.
-        // remove directory.
-        std::cout << "The gazebo process is not alive.\n";
+        if(kill(pid, 0) == 0) 
+        {
+          // a gazebo process is still alive.
+          errStream << "directory [" <<  this->filename
+            <<  "] already exists (previous crash?)\n"
+            << "gazebo (pid=" << pid << ") is still running.\n" 
+            << "re-launch gazebo with a different server id or kill the 
previous instance" ;
+          throw(errStream.str());
+        } 
+        else 
+        {
+          // the gazebo process is not alive.
+          // remove directory.
+          std::cout << "directory [" <<  this->filename
+            <<  "] already exists (previous crash?)\n"
+            << "but the owner gazebo server (pid=" << pid << ") is not 
running.\n" 
+            << "deleting the directory [" <<  this-> filename 
+            << " old  information" ;
 
-        // remove the existing directory.
-        std::string cmd = "rm -rf '" + this->filename + "'";
-        if(system(cmd.c_str()) != 0) {
-          errStream << "couldn't remove directory [" <<  this->filename << "]";
-          throw(errStream.str());
+          // remove the existing directory.
+          std::string cmd = "rm -rf '" + this->filename + "'";
+          if(system(cmd.c_str()) != 0) {
+            errStream << "couldn't remove directory [" <<  this->filename << 
"]";
+            throw(errStream.str());
+          }
         }
       }
     }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to