diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-04-06 13:40:48 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-04-06 13:40:48 +0200 |
| commit | 748552d792c3b7042cb1ea39d86f52a5d6f2208c (patch) | |
| tree | 51920468bf791944b302ccb1f0db4ad8855520de /src/custommem.c | |
| parent | ff50b0c39178c9065b4815c68cd7c5cab3fdf336 (diff) | |
| download | box64-748552d792c3b7042cb1ea39d86f52a5d6f2208c.tar.gz box64-748552d792c3b7042cb1ea39d86f52a5d6f2208c.zip | |
Unlock all mutex on child process when forking
Diffstat (limited to 'src/custommem.c')
| -rw-r--r-- | src/custommem.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/custommem.c b/src/custommem.c index 0358543d..80453230 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -882,6 +882,15 @@ void* findBlockNearHint(void* hint, size_t size) } #undef LOWEST +static void atfork_child_custommem(void) +{ + // unlock mutex if it was lock before the fork + pthread_mutex_unlock(&mutex_blocks); + pthread_mutex_unlock(&mutex_prot); +#ifdef DYNAREC + pthread_mutex_unlock(&mutex_mmap); +#endif +} void init_custommem_helper(box64context_t* ctx) { @@ -904,6 +913,7 @@ void init_custommem_helper(box64context_t* ctx) #error Unsupported architecture! #endif #endif + pthread_atfork(NULL, NULL, atfork_child_custommem); } void fini_custommem_helper(box64context_t *ctx) |