do not leak process handles opened by fork_process/CreateProcess
[git-cheetah/kirill.git] / compat / pread.c
blob624030c09a58b5623cc28a7eacef4733f196df26
1 #include "../common/git-compat-util.h"
3 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
5 off_t current_offset;
6 ssize_t rc;
8 current_offset = lseek(fd, 0, SEEK_CUR);
10 if (lseek(fd, offset, SEEK_SET) < 0)
11 return -1;
13 rc = read_in_full(fd, buf, count);
15 if (current_offset != lseek(fd, current_offset, SEEK_SET))
16 return -1;
17 return rc;