node/test/wasi/c/pthread.c
toyobayashi 8cc5e57af3 lib: expose setupInstance method on WASI class
PR-URL: https://github.com/nodejs/node/pull/57214
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2025-07-07 08:41:16 -07:00

24 lines
391 B
C

#include <assert.h>
#include <pthread.h>
#include <unistd.h>
void* worker(void* data) {
int* result = (int*) data;
sleep(1);
*result = 42;
return NULL;
}
int main() {
pthread_t thread = NULL;
int result = 0;
int r = pthread_create(&thread, NULL, worker, &result);
assert(r == 0);
r = pthread_join(thread, NULL);
assert(r == 0);
assert(result == 42);
return 0;
}