Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix signal_handler_run_in_c_thread test #2701

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static int thread_started = 0;

static void* in_thread(void* unused)
{
(void) pthread_cond_signal(&cond);
pthread_mutex_lock(&mutex);
thread_started = 1;
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
/* Signal to be received in this thread by the OCaml signal handler */
while (1);
}
Expand All @@ -16,7 +20,11 @@ value test_signal_handler_run_in_c_thread(value unit)
{
pthread_t thread;
pthread_create(&thread, NULL, &in_thread, NULL);
pthread_cond_wait(&cond, &mutex);
pthread_mutex_lock(&mutex);
while (!thread_started) {
pthread_cond_wait(&cond, &mutex);
}
pthread_mutex_unlock(&mutex);
pthread_kill(thread, SIGUSR1);
return Val_unit;
}
Loading