[PATCH weston 2/2] os: Check for EINTR on ftruncate()

Derek Foreman derekf at osg.samsung.com
Thu Mar 23 16:59:23 UTC 2017


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 at osg.samsung.com>
---
 shared/os-compatibility.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/shared/os-compatibility.c b/shared/os-compatibility.c
index 6b2f3770..e19fb61b 100644
--- a/shared/os-compatibility.c
+++ b/shared/os-compatibility.c
@@ -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;
-- 
2.11.0



More information about the wayland-devel mailing list