pread
pread attempts to read up to the requested byte count from a seekable file at an explicit offset without changing the open file description's current position.
Unlike a separate seek followed by read, positional reading does not depend on another holder leaving the shared cursor untouched. It still permits a successful short transfer. [1]
For an exact-length application record, continue at the initial offset plus bytes actually returned, reducing the remaining count accordingly. A positive-count regular-file read returning zero before that range is complete means premature EOF for that contract; a zero-count request is not an EOF test. [2]
Explicit positioning does not freeze content. Concurrent writes or truncation can invalidate an application's expected version even when its byte count is complete. This is a protocol-design limitation, not a storage-failure measurement.
Relations
Advantages
- Supports independent read positions on one shared open file description.
Limitations
- Requires a seekable object; pipes and sockets do not provide this operation.
- Range completion alone establishes neither a snapshot nor data authenticity.
Citations
- Linux man-pages 6.19: pread(2), positional access and partial transfers
- Linux man-pages 6.19: read(2), return counts and end of file
Further reading
Sources & caveats
- Source review of Linux man-pages 6.19; reader continuation and source-version checks are application-design implications.