emscripten-core / emscripten-core/emscripten
Node.js pthread implementation shutting down before pthread prints.
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Consider the following test case:
`test.c`
```c
#include
#include
#include
#include
void* thread_main(void* param) {
printf("thread_main\n");
exit(0);
}
int main(int argc, char** argv) {
pthread_t thread;
pthread_create(&thread, 0, thread_main, NULL);
emscripten_exit_with_live_runtime();
}
```
`emcc test.c -o a.html -pthread -sEXIT_RUNTIME=1`
---------------
The main thread creates a pthread, and then yields out from `main()`, leaving the runtime alive on the main thread.
The pthread then does a print, and exits the whole program.
When run in `node`, this application prints nothing and quits (no `thread_main` printed).
When run in a browser, the printf does appear, but calling `exit(0)` does not shut down the runtime.
Contributor guide
Assessment
This issue has not been assessed yet.