mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 00:38:31 +00:00
Attempt to fix MODE=dbg Windows execve() flake
This commit is contained in:
parent
7b67b20dae
commit
035b0e2a62
5 changed files with 68 additions and 84 deletions
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/atomic.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
|
@ -57,11 +58,10 @@
|
|||
__msabi extern typeof(CloseHandle) *const __imp_CloseHandle;
|
||||
__msabi extern typeof(TerminateProcess) *const __imp_TerminateProcess;
|
||||
|
||||
extern pthread_mutex_t __sig_worker_lock;
|
||||
extern atomic_int __sig_worker_state;
|
||||
|
||||
static void sys_execve_nt_abort(sigset_t sigmask) {
|
||||
_pthread_unlock();
|
||||
_pthread_mutex_unlock(&__sig_worker_lock);
|
||||
__sig_worker_state &= ~2;
|
||||
__sig_unblock(sigmask);
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,10 @@ textwindows int sys_execve_nt(const char *program, char *const argv[],
|
|||
|
||||
// execve() needs to be @asyncsignalsafe
|
||||
sigset_t sigmask = __sig_block();
|
||||
_pthread_mutex_lock(&__sig_worker_lock); // order matters
|
||||
_pthread_lock(); // order matters
|
||||
__sig_worker_state |= 2;
|
||||
for (;;)
|
||||
if (__sig_worker_state & 1)
|
||||
break;
|
||||
|
||||
// new process should be a child of our parent
|
||||
int64_t hParentProcess =
|
||||
|
@ -176,6 +178,7 @@ textwindows int sys_execve_nt(const char *program, char *const argv[],
|
|||
STRACE("warning: execve() lingering due to non-cosmo parent process");
|
||||
|
||||
// terminate other threads
|
||||
_pthread_lock();
|
||||
struct Dll *e;
|
||||
struct PosixThread *me = _pthread_self();
|
||||
for (e = dll_first(_pthread_list); e; e = dll_next(_pthread_list, e)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue