File: test_pthread_exit_runtime.c

package info (click to toggle)
emscripten 2.0.12~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 108,440 kB
  • sloc: ansic: 510,324; cpp: 384,763; javascript: 84,341; python: 51,362; sh: 50,019; pascal: 4,159; makefile: 3,409; asm: 2,150; lisp: 1,869; ruby: 488; cs: 142
file content (32 lines) | stat: -rw-r--r-- 723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <assert.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

pthread_t t;

void* thread_main_exit(void* arg) {
  printf("calling exit\n");
  exit(42);
}

int main() {
  printf("main\n");
  int rc = pthread_create(&t, NULL, thread_main_exit, NULL);
  assert(rc == 0);
  void* thread_rtn = 0;
  rc = pthread_join(t, &thread_rtn);
  assert(rc == 0);
#if EXIT_RUNTIME
  printf("done join -- should never get here\n");
  return 1;
#else
  // Since EXIT_RUNTIME is not set the exit() in the thread is not expected to
  // bring down the whole process, only itself.
  printf("done join -- thread exited with %ld\n", (intptr_t)thread_rtn);
#ifdef REPORT_RESULT
  REPORT_RESULT(43);
#endif
  return 43;
#endif
}