diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-11-03 08:16:03 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-11-03 08:16:49 +0100 |
| commit | a5d2b5ed451ca8414bc3a82288fbbf63fcc97070 (patch) | |
| tree | dfe6366a3cd909c79d36c7cf251dec832eba635b /libdecor/src/os-compatibility.c | |
| parent | 33f01ecb836f9bd70447fcd7ab0f7eda27d224db (diff) | |
libdecor: update from source git repo (commit e87dcfda)
This brings the GTK plugin inside the master libdecor git repo.
Diffstat (limited to 'libdecor/src/os-compatibility.c')
| -rw-r--r-- | libdecor/src/os-compatibility.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libdecor/src/os-compatibility.c b/libdecor/src/os-compatibility.c index 50beb79f8..8287da0e6 100644 --- a/libdecor/src/os-compatibility.c +++ b/libdecor/src/os-compatibility.c @@ -29,6 +29,7 @@ #include <unistd.h> #include <fcntl.h> #include <errno.h> +#include <signal.h> #include <string.h> #include <stdlib.h> @@ -86,11 +87,27 @@ static int os_resize_anonymous_file(int fd, off_t size) { #ifdef HAVE_POSIX_FALLOCATE + sigset_t mask; + sigset_t old_mask; + + /* posix_fallocate() might be interrupted, so we need to check + * for EINTR and retry in that case. + * However, in the presence of an alarm, the interrupt may trigger + * repeatedly and prevent a large posix_fallocate() to ever complete + * successfully, so we need to first block SIGALRM to prevent + * this. + */ + sigemptyset(&mask); + sigaddset(&mask, SIGALRM); + sigprocmask(SIG_BLOCK, &mask, &old_mask); /* - * Filesystems that do support fallocate will return EINVAL or + * Filesystems that do not support fallocate will return EINVAL or * EOPNOTSUPP. In this case we need to fall back to ftruncate */ - errno = posix_fallocate(fd, 0, size); + do { + errno = posix_fallocate(fd, 0, size); + } while (errno == EINTR); + sigprocmask(SIG_SETMASK, &old_mask, NULL); if (errno == 0) return 0; else if (errno != EINVAL && errno != EOPNOTSUPP) |
