Fix getting a zone name from gid 42/52742/2 accepted/tizen/mobile/20151127.070358 accepted/tizen/tv/20151127.070403 accepted/tizen/wearable/20151127.070408 submit/tizen/20151127.042132
authorjooseong.lee <jooseong.lee@samsung.com>
Thu, 26 Nov 2015 10:21:53 +0000 (19:21 +0900)
committerjooseong.lee <jooseong.lee@samsung.com>
Thu, 26 Nov 2015 11:01:37 +0000 (20:01 +0900)
Assume there are no containers if cpuset dosen't present

Change-Id: If97fd885595a3ace9691fe2ad88ec4219f43909f
Signed-off-by: jooseong.lee <jooseong.lee@samsung.com>
src/common/zone-utils.cpp

index 95162c4..b3c93c9 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "zone-utils.h"
 
+#include <unistd.h>
 #include <fstream>
 
 #include <dpl/log/log.h>
@@ -49,6 +50,12 @@ bool getZoneIdFromPid(int pid, std::string& zoneId)
     //open /proc/<pid>/cpuset and get its contents
     const std::string path = "/proc/" + std::to_string(pid) + "/cpuset";
 
+    //Assume there are no containers if cpuset dosen't present
+    if(access(path.c_str(), F_OK)!= 0) {
+        zoneId = ZONE_HOST;
+        return true;
+    }
+
     std::ifstream cpusetFile(path);
     if (!cpusetFile) {
         LogError("Failed to open cpuset");