Skip to content

Conversation

@oschwald
Copy link
Member

@oschwald oschwald commented Apr 6, 2015

After a fork, the file handle of both the parent and child process will share the same file table entry, which holds state such as the offset. There is unfortunately no way to clone the file table entry (dup only duplicates the file descriptor). This leads to corrupted reads when another process changes the offset unexpectedly. In Python 3.x, we use pread when available, as it does not rely on the offset in the file table. On Python's without pread, we rely on a lock. Reported in #22 on GeoIP2-python.

autarch added a commit that referenced this pull request Apr 7, 2015
Use os.pread or a lock in MODE_FILE
@autarch autarch merged commit 10bdfab into master Apr 7, 2015
@autarch autarch deleted the greg/no-auto-file-mode branch April 7, 2015 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants