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
""" 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 """
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