summaryrefslogtreecommitdiff
path: root/src/lib/eina_mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eina_mmap.c')
-rw-r--r--src/lib/eina_mmap.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/eina_mmap.c b/src/lib/eina_mmap.c
index b99a542..90809a2 100644
--- a/src/lib/eina_mmap.c
+++ b/src/lib/eina_mmap.c
@@ -164,10 +164,7 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
sa.sa_sigaction = _eina_mmap_safe_sigbus;
sa.sa_flags = SA_RESTART | SA_SIGINFO;
sigemptyset(&sa.sa_mask);
- /* FIXME: This is rubbish. We return EINA_FALSE whether sigaction
- * fails or not. And we never set mmap_safe, so we always hit this
- * code path. */
- if (sigaction(SIGBUS, &sa, NULL) == 0) return EINA_FALSE;
+ if (sigaction(SIGBUS, &sa, NULL) == 0) goto done;
/* setup of SIGBUS handler failed, lets close zero page dev and fail */
close(_eina_mmap_zero_fd);
_eina_mmap_zero_fd = -1;
@@ -176,8 +173,14 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
else
{
/* reset signal handler to default for SIGBUS */
+ if (_eina_mmap_zero_fd >= 0)
+ {
+ close(_eina_mmap_zero_fd);
+ _eina_mmap_zero_fd = -1;
+ }
signal(SIGBUS, SIG_DFL);
}
+done:
mmap_safe = enabled;
return mmap_safe;
#endif