Salome HOME
Avoid MED file reading failure caused by low memory
[modules/smesh.git] / src / MEDWrapper / Factory / MED_Factory.cxx
index 3bb54574e402c2106f117aae1986d71e1b00bb22..f4108be584cd1a671031c1d2b4def94335926624 100644 (file)
@@ -25,6 +25,7 @@
 #include "MED_V2_2_Wrapper.hxx"
 
 #include <stdio.h>
 #include "MED_V2_2_Wrapper.hxx"
 
 #include <stdio.h>
+#include <errno.h>
 #include <sstream>
 
 #include <med.h>
 #include <sstream>
 
 #include <med.h>
@@ -53,7 +54,7 @@ namespace MED
 #ifndef WIN32
     if (access(theFileName.c_str(),F_OK))
       return aVersion;
 #ifndef WIN32
     if (access(theFileName.c_str(),F_OK))
       return aVersion;
-    if(theDoPreCheckInSeparateProcess){
+    if ( theDoPreCheckInSeparateProcess ) {
       // First check, is it possible to deal with the file
       std::ostringstream aStr;
       // File name is in quotes for the case of space(s) inside it (PAL13009)
       // First check, is it possible to deal with the file
       std::ostringstream aStr;
       // File name is in quotes for the case of space(s) inside it (PAL13009)
@@ -64,8 +65,9 @@ namespace MED
       std::string aCommand = aStr.str();
       int aStatus = system(aCommand.c_str());
 
       std::string aCommand = aStr.str();
       int aStatus = system(aCommand.c_str());
 
-      BEGMSG(MYDEBUG,"aCommand = '"<<aCommand<<"'; aStatus = "<<aStatus<<std::endl);
-      if(aStatus != 0)
+      BEGMSG( MYDEBUG,"aCommand = '" << aCommand << "'; aStatus = " << aStatus
+             << "; errno = " << errno << " = " << strerror( errno ) << std::endl );
+      if ( aStatus != 0 && errno != EAGAIN && errno != ENOMEM ) // "Cannot allocate memory" is OK
         return aVersion;
     }
 #endif
         return aVersion;
     }
 #endif