Skip to content

Commit

Permalink
mach jl_deliver_handled_sigint fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubwro committed Sep 19, 2023
1 parent 9ddbf8b commit 265eff0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/signals-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,34 @@ static void jl_try_deliver_sigint(void)
HANDLE_MACH_ERROR("thread_resume", ret);
}

static void jl_deliver_handled_sigint(void)
{
jl_ptls_t ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[0];
mach_port_t thread = pthread_mach_thread_np(ptls2->system_id);

kern_return_t ret = thread_suspend(thread);
HANDLE_MACH_ERROR("thread_suspend", ret);

// This aborts `sleep` and other syscalls.
// ret = thread_abort_safely(thread);
// HANDLE_MACH_ERROR("thread_abort", ret);

int force = jl_check_force_sigint();
if (force || (!ptls2->defer_signal && ptls2->io_wait)) {
jl_safepoint_consume_sigint();
if (force)
jl_safe_printf("WARNING: Force throwing a SIGINT\n");
jl_clear_force_sigint();
jl_throw_in_thread(ptls2, thread, jl_interrupt_exception);
}
else {
jl_wake_libuv();
}

ret = thread_resume(thread);
HANDLE_MACH_ERROR("thread_resume", ret);
}

static void JL_NORETURN jl_exit_thread0_cb(int signo)
{
CFI_NORETURN
Expand Down
3 changes: 2 additions & 1 deletion src/signals-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ JL_DLLEXPORT void jl_profile_stop_timer(void)
#error no profile tools available

#endif
#endif // HAVE_MACH

static void jl_deliver_handled_sigint(void)
{
Expand All @@ -612,6 +611,8 @@ static void jl_deliver_handled_sigint(void)
jl_wake_thread(0);
}

#endif // HAVE_MACH

static void allocate_segv_handler(void)
{
struct sigaction act;
Expand Down

0 comments on commit 265eff0

Please sign in to comment.