|
48 | 48 | #define pthread_workqueue_t void*
|
49 | 49 | #endif
|
50 | 50 |
|
| 51 | +static void _dispatch_sig_thread(void *ctxt); |
51 | 52 | static void _dispatch_cache_cleanup(void *value);
|
52 | 53 | static void _dispatch_sync_f(dispatch_queue_t dq, void *ctxt,
|
53 | 54 | dispatch_function_t func, pthread_priority_t pp);
|
@@ -5693,6 +5694,11 @@ dispatch_main(void)
|
5693 | 5694 | _dispatch_object_debug(&_dispatch_main_q, "%s", __func__);
|
5694 | 5695 | _dispatch_program_is_probably_callback_driven = true;
|
5695 | 5696 | _dispatch_ktrace0(ARIADNE_ENTER_DISPATCH_MAIN_CODE);
|
| 5697 | +#ifdef __linux__ |
| 5698 | + pthread_key_t dispatch_main_key; |
| 5699 | + pthread_key_create(&dispatch_main_key, _dispatch_sig_thread); |
| 5700 | + pthread_setspecific(dispatch_main_key, &dispatch_main_key); // anything non NULL really |
| 5701 | +#endif |
5696 | 5702 | pthread_exit(NULL);
|
5697 | 5703 | DISPATCH_INTERNAL_CRASH(errno, "pthread_exit() returned");
|
5698 | 5704 | #if HAVE_PTHREAD_MAIN_NP
|
@@ -5776,11 +5782,13 @@ _dispatch_queue_cleanup2(void)
|
5776 | 5782 | // overload the "probably" variable to mean that dispatch_main() or
|
5777 | 5783 | // similar non-POSIX API was called
|
5778 | 5784 | // this has to run before the DISPATCH_COCOA_COMPAT below
|
| 5785 | +#ifndef __linux__ |
5779 | 5786 | if (_dispatch_program_is_probably_callback_driven) {
|
5780 | 5787 | _dispatch_barrier_async_detached_f(_dispatch_get_root_queue(
|
5781 | 5788 | _DISPATCH_QOS_CLASS_DEFAULT, true), NULL, _dispatch_sig_thread);
|
5782 | 5789 | sleep(1); // workaround 6778970
|
5783 | 5790 | }
|
| 5791 | +#endif |
5784 | 5792 |
|
5785 | 5793 | #if DISPATCH_COCOA_COMPAT
|
5786 | 5794 | dispatch_once_f(&_dispatch_main_q_port_pred, dq,
|
|
0 commit comments