VirtualBox

Changeset 90392 in vbox


Ignore:
Timestamp:
Jul 29, 2021 8:25:50 AM (3 years ago)
Author:
vboxsync
Message:

IPRT/RTThreadCreate: Added RTTHREADFLAGS_NO_SIGNALS (posix only). bugref:6695

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/thread.h

    r88688 r90392  
    261261     *  COINIT_SPEED_OVER_MEMORY.   Ignored on non-windows platforms.  */
    262262    RTTHREADFLAGS_COM_STA = RT_BIT(2),
     263
     264    /** Mask all signals that we can mask.  Ignored on most non-posix platforms.
     265     * @note RTThreadPoke() will not necessarily work for a thread create with
     266     *       this flag. */
     267    RTTHREADFLAGS_NO_SIGNALS = RT_BIT(3),
    263268
    264269    /** Mask of valid flags, use for validation. */
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r89870 r90392  
    238238}
    239239
    240 static void rtThreadPosixBlockSignals(void)
    241 {
     240static void rtThreadPosixBlockSignals(PRTTHREADINT pThread)
     241{
     242    /*
     243     * Mask all signals, including the poke one, if requested.
     244     */
     245    if (   pThread
     246        && (pThread->fFlags & RTTHREADFLAGS_NO_SIGNALS))
     247    {
     248        sigset_t SigSet;
     249        sigfillset(&SigSet);
     250        int rc = sigprocmask(SIG_BLOCK, &SigSet, NULL);
     251        AssertMsg(rc == 0, ("rc=%Rrc errno=%d\n", RTErrConvertFromErrno(errno), errno)); RT_NOREF(rc);
     252    }
    242253    /*
    243254     * Block SIGALRM - required for timer-posix.cpp.
     
    245256     * It will not help much if someone creates threads directly using pthread_create. :/
    246257     */
    247     if (!RTR3InitIsUnobtrusive())
     258    else if (!RTR3InitIsUnobtrusive())
    248259    {
    249260        sigset_t SigSet;
     
    255266#ifdef RTTHREAD_POSIX_WITH_POKE
    256267    /*
    257      * bird 2020-10-28: Not entirely sure we do this, but it makes sure the signal works
     268     * bird 2020-10-28: Not entirely sure why we do this, but it makes sure the signal works
    258269     *                  on the new thread.  Probably some pre-NPTL linux reasons.
    259270     */
     
    286297    rtThreadPosixSelectPokeSignal();
    287298#endif
    288     rtThreadPosixBlockSignals();
     299    rtThreadPosixBlockSignals(NULL);
    289300}
    290301
     
    331342DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)
    332343{
    333     rtThreadPosixBlockSignals();
     344    rtThreadPosixBlockSignals(pThread);
    334345
    335346    int rc = pthread_setspecific(g_SelfKey, pThread);
     
    367378#endif
    368379
    369     rtThreadPosixBlockSignals();
     380    rtThreadPosixBlockSignals(pThread);
    370381
    371382    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette