Skip to content

Commit

Permalink
Don't close self.file before we know we can reopen it
Browse files Browse the repository at this point in the history
If file permissions change, reopening will fail, and we'll end up
getting an exception, a closed self.file, and a background thread that
will die next time it tries to write to the now-closed file, leaving the
child process writing to a pipe until the pipe buffer fills up at some
point in the future (see also bug #1).
  • Loading branch information
mgedmin committed Apr 15, 2015
1 parent 7f82548 commit b346f86
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/zdaemon/zdrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,10 @@ def copy(self):
self.write(os.read(fd, 8192))

def reopen(self):
new_file = open(self.filename, 'ab', 0)
with self.lock:
self.file.close()
self.file = open(self.filename, 'ab', 0)
self.file = new_file
self.write = self.file.write


Expand Down

0 comments on commit b346f86

Please sign in to comment.