summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/kit/shared_memory.win32.c10
-rw-r--r--source/tests/test_interprocess.c5
2 files changed, 12 insertions, 3 deletions
diff --git a/source/kit/shared_memory.win32.c b/source/kit/shared_memory.win32.c
index c6cc3d3..5b5c1b0 100644
--- a/source/kit/shared_memory.win32.c
+++ b/source/kit/shared_memory.win32.c
@@ -69,7 +69,13 @@ kit_shared_memory_t kit_shared_memory_open(kit_str_t name, i64 size,
kit_status_t kit_shared_memory_close(kit_shared_memory_t *mem) {
assert(mem != NULL);
- UnmapViewOfFile(mem->bytes);
- CloseHandle(mem->_handle);
+ i32 status = KIT_OK;
+
+ if (!UnmapViewOfFile(mem->bytes))
+ status |= KIT_ERROR_MUNMAP_FAILED;
+ if (!CloseHandle(mem->_handle))
+ status |= KIT_ERROR_UNLINK_FAILED;
+
+ return status;
}
#endif
diff --git a/source/tests/test_interprocess.c b/source/tests/test_interprocess.c
index 58044bf..5afc0c8 100644
--- a/source/tests/test_interprocess.c
+++ b/source/tests/test_interprocess.c
@@ -25,7 +25,10 @@ int run_writer() {
while (mem.bytes[0] != STATE_DONE) thrd_yield();
- return kit_shared_memory_close(&mem);
+ if (kit_shared_memory_close(&mem) != KIT_OK)
+ return 1;
+
+ return 0;
}
int run_reader() {