summaryrefslogtreecommitdiffstats
path: root/src/util/find_uid.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-04-02 17:26:05 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-04-20 10:55:14 -0400
commit9d7d4458d94d0aac0a7edf999368eb18f89cb76a (patch)
treeb443c2ed560bc5f61cae78e94ceeb795fa1f83b4 /src/util/find_uid.c
parent9959c512ac3ba36f7a0db7614f0357ce0bae748f (diff)
downloadsssd-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.tar.gz
sssd-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.tar.xz
sssd-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.zip
Convert read and write operations to sss_atomic_read
https://fedorahosted.org/sssd/ticket/1209
Diffstat (limited to 'src/util/find_uid.c')
-rw-r--r--src/util/find_uid.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/util/find_uid.c b/src/util/find_uid.c
index 77b9f22a8..d34a4abd2 100644
--- a/src/util/find_uid.c
+++ b/src/util/find_uid.c
@@ -107,15 +107,13 @@ static errno_t get_uid_from_pid(const pid_t pid, uid_t *uid)
goto fail_fd;
}
- while ((ret = read(fd, buf, BUFSIZE)) != 0) {
- if (ret == -1) {
- error = errno;
- if (error == EINTR || error == EAGAIN) {
- continue;
- }
- DEBUG(1, ("read failed [%d][%s].\n", error, strerror(error)));
- goto fail_fd;
- }
+ errno = 0;
+ ret = sss_atomic_read_s(fd, buf, BUFSIZE);
+ if (ret == -1) {
+ error = errno;
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("read failed [%d][%s].\n", error, strerror(error)));
+ goto fail_fd;
}
/* Guarantee NULL-termination in case we read the full BUFSIZE somehow */