Skip to content

Commit 5a1d6bf

Browse files
committed
wasi-threads: make a return from _start a proc_exit(0) equivalent
necessary for the current wasi-libc. cf. WebAssembly/wasi-libc#367
1 parent 251caf8 commit 5a1d6bf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/wasi_threads.c

+12
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ void
129129
wasi_threads_instance_join(struct wasi_threads_instance *wasi)
130130
{
131131
toywasm_mutex_lock(&wasi->lock);
132+
#if 1
133+
/*
134+
* https://github.com/WebAssembly/wasi-threads/issues/21
135+
*
136+
* option b.
137+
* proc_exit(0) equivalent. terminate all other threads.
138+
*/
139+
if (!wasi->interrupt) {
140+
xlog_trace("Emulating proc_exit(0) on a return from _start");
141+
wasi->interrupt = 1;
142+
}
143+
#endif
132144
while (wasi->nrunners > 0) {
133145
int ret = pthread_cond_wait(&wasi->cv, &wasi->lock.lock);
134146
assert(ret == 0);

0 commit comments

Comments
 (0)