ソースを参照

HPCC-15715 Use pread for getMemUsage()

Signed-off-by: Mark Kelly <mark.kelly@lexisnexis.com>
Mark Kelly 9 年 前
コミット
ce98ac70c8
1 ファイル変更3 行追加6 行削除
  1. 3 6
      system/jlib/jdebug.cpp

+ 3 - 6
system/jlib/jdebug.cpp

@@ -1108,9 +1108,8 @@ static void getMemUsage(unsigned &inuse,unsigned &active,unsigned &total,unsigne
         memfd = open("/proc/meminfo",O_RDONLY);
         memfd = open("/proc/meminfo",O_RDONLY);
     if (memfd==-1)
     if (memfd==-1)
         return;
         return;
-    lseek(memfd, 0L, 0);
-    char buf[1024];
-    size32_t l = read(memfd, buf, sizeof(buf)-1);
+    char buf[2048];
+    size32_t l = pread(memfd, buf, sizeof(buf)-1, 0L);
     if ((int)l<=0)
     if ((int)l<=0)
         return;
         return;
     buf[l] = 0;
     buf[l] = 0;
@@ -1302,10 +1301,8 @@ void getPeakMemUsage(memsize_t &peakVm,memsize_t &peakResident)
         memfd = open("/proc/self/status",O_RDONLY);
         memfd = open("/proc/self/status",O_RDONLY);
     if (memfd==-1)
     if (memfd==-1)
         return;
         return;
-    lseek(memfd, 0L, 0);
-
     char buf[2048];
     char buf[2048];
-    size32_t l = read(memfd, buf, sizeof(buf)-1);
+    size32_t l = pread(memfd, buf, sizeof(buf)-1, 0L);
     if ((int)l<=0)
     if ((int)l<=0)
         return;
         return;
     buf[l] = 0;
     buf[l] = 0;