Skip to content

Commit a069cf0

Browse files
committed
Fix keepRuntimeAlive for pthreads
Still need to figure out how to test this. Fixes: #22889
1 parent 655011f commit a069cf0

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/library.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,16 +2078,11 @@ addToLibrary({
20782078
// at runtime.
20792079
$keepRuntimeAlive__deps: ['$runtimeKeepaliveCounter'],
20802080
$keepRuntimeAlive: () => noExitRuntime || runtimeKeepaliveCounter > 0,
2081-
#elif !EXIT_RUNTIME
2082-
// When `noExitRuntime` is not include and EXIT_RUNTIME=0 then we know the
2081+
#elif !EXIT_RUNTIME && !PTHREADS
2082+
// When `noExitRuntime` is not included and EXIT_RUNTIME=0 then we know the
20832083
// runtime can never exit (i.e. should always be kept alive).
2084-
// However for pthreads we always default to allowing the runtime to exit
2085-
// otherwise threads never exit and are not joinable.
2086-
#if PTHREADS
2087-
$keepRuntimeAlive: () => !ENVIRONMENT_IS_PTHREAD,
2088-
#else
2084+
// However for pthreads we always always need to allow the runtime to exit
20892085
$keepRuntimeAlive: () => true,
2090-
#endif
20912086
#else
20922087
$keepRuntimeAlive__deps: ['$runtimeKeepaliveCounter'],
20932088
$keepRuntimeAlive: () => runtimeKeepaliveCounter > 0,

test/test_other.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13640,8 +13640,12 @@ def test_pthread_icu(self):
1364013640
self.do_other_test('test_pthread_icu.cpp')
1364113641

1364213642
@node_pthreads
13643-
def test_pthread_set_main_loop(self):
13644-
self.do_other_test('test_pthread_set_main_loop.c')
13643+
@parameterized({
13644+
'': ([],),
13645+
'strict': (['-sSTRICT'],),
13646+
})
13647+
def test_pthread_set_main_loop(self, args):
13648+
self.do_other_test('test_pthread_set_main_loop.c', emcc_args=args)
1364513649

1364613650
# unistd tests
1364713651

0 commit comments

Comments
 (0)