os: Check for EINTR on ftruncate()

The man page indicates that ftruncate() can set errno to EINTR, so test
for this.

I have not actually been able to provoke an EINTR error from ftruncate()
in testing though.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Derek Foreman 2017-03-23 11:59:23 -05:00 committed by Quentin Glidic
parent 91d4bce7c3
commit 5ef6bd7eee
No known key found for this signature in database
GPG Key ID: AC203F96E2C34BB7
1 changed files with 3 additions and 1 deletions

View File

@ -187,7 +187,9 @@ os_create_anonymous_file(off_t size)
return -1;
}
#else
ret = ftruncate(fd, size);
do {
ret = ftruncate(fd, size);
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
close(fd);
return -1;