fix corrupted log messages in log file
authorDohyung Kim <dohyung2.kim@samsung.com>
Tue, 25 Apr 2017 07:36:43 +0000 (16:36 +0900)
committeradmin <yuhuan.yang@samsung.com>
Wed, 12 Jul 2017 15:33:54 +0000 (23:33 +0800)
os.ftruncate() won't reset the file pointer
os.lseek(fd, 0, os.SEEK_SET) is needed after os.ftruncate(fd, 0)

Signed-off-by: Dohyung Kim <dohyung2.kim@samsung.com>
Change-Id: I94bdd3993afccee2ea2d8903aa29505fec13c957

mic/msger.py

index 49bdc2fd478018b474b7cf541c15775b560c9367..31ac9bdb1a5d5d3f4b8bb9665a39f2bc806d6651 100644 (file)
@@ -133,6 +133,7 @@ class RedirectedStderr(object):
         """ Truncate the tempfile to size zero """
         if self.tmpfile:
             os.ftruncate(self.tmpfile.fileno(), 0)
+            os.lseek(self.tmpfile.fileno(), 0, os.SEEK_SET)
 
     def redirect(self):
         """ Redirect stderr to the temp file """
@@ -154,6 +155,7 @@ class RedirectedStderr(object):
             self.tmpfile.seek(0, 0)
             self.value = self.tmpfile.read()
             os.ftruncate(self.tmpfile.fileno(), 0)
+            os.lseek(self.tmpfile.fileno(), 0, os.SEEK_SET)
             return self.value
         return None