fix corrupted log messages in log file 90/126990/1
authorDohyung Kim <dohyung2.kim@samsung.com>
Tue, 25 Apr 2017 07:36:43 +0000 (16:36 +0900)
committerDohyung Kim <dohyung2.kim@samsung.com>
Tue, 25 Apr 2017 12:26:06 +0000 (21:26 +0900)
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 49bdc2f..31ac9bd 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