VirtualBox

Changeset 44456 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Jan 30, 2013 10:59:47 AM (12 years ago)
Author:
vboxsync
Message:

Runtime: add unobtrusive initialisation option which does not block SIGALRM.

Location:
trunk/src/VBox/Runtime/r3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/init.cpp

    r40317 r44456  
    100100static char **              g_papszrtOrgArgs;
    101101
     102/** Are we running in unobtrusive mode? */
     103static bool                 g_fUnobtrusive = false;
     104
    102105/**
    103106 * Program start nanosecond TS.
     
    341344#endif
    342345
     346    g_fUnobtrusive = fFlags & RTR3INIT_FLAGS_UNOBTRUSIVE;
     347
    343348#if !defined(IN_GUEST) && !defined(RT_NO_GIP)
    344349# ifdef VBOX
     
    484489{
    485490    /* no entry log flow, because prefixes and thread may freak out. */
    486     Assert(!(fFlags & ~(RTR3INIT_FLAGS_DLL | RTR3INIT_FLAGS_SUPLIB)));
     491    Assert(!(fFlags & ~(  RTR3INIT_FLAGS_DLL
     492                        | RTR3INIT_FLAGS_SUPLIB
     493                        | RTR3INIT_FLAGS_UNOBTRUSIVE)));
    487494    Assert(!(fFlags & RTR3INIT_FLAGS_DLL) || cArgs == 0);
    488495
     
    558565}
    559566
     567RTR3DECL(bool) RTR3InitIsUnobtrusive(void)
     568{
     569    return g_fUnobtrusive;
     570}
    560571
    561572#if 0 /** @todo implement RTR3Term. */
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r44025 r44456  
    6363#include <iprt/asm.h>
    6464#include <iprt/err.h>
     65#include <iprt/initterm.h>
    6566#include <iprt/string.h>
    6667#include "internal/thread.h"
     
    149150
    150151    g_iSigPokeThread = -1;
    151     for (unsigned iSig = 0; iSig < RT_ELEMENTS(s_aiSigCandidates); iSig++)
    152     {
    153         struct sigaction SigActOld;
    154         if (!sigaction(s_aiSigCandidates[iSig], NULL, &SigActOld))
     152    if (!RTR3InitIsUnobtrusive())
     153    {
     154        for (unsigned iSig = 0; iSig < RT_ELEMENTS(s_aiSigCandidates); iSig++)
    155155        {
    156             if (   SigActOld.sa_handler == SIG_DFL
    157                 || SigActOld.sa_handler == rtThreadPosixPokeSignal)
     156            struct sigaction SigActOld;
     157            if (!sigaction(s_aiSigCandidates[iSig], NULL, &SigActOld))
    158158            {
    159                 struct sigaction SigAct;
    160                 RT_ZERO(SigAct);
    161                 SigAct.sa_handler = rtThreadPosixPokeSignal;
    162                 SigAct.sa_flags   = 0;
    163                 sigfillset(&SigAct.sa_mask);
    164 
    165                 /* ASSUMES no sigaction race... (lazy bird) */
    166                 if (!sigaction(s_aiSigCandidates[iSig], &SigAct, NULL))
     159                if (   SigActOld.sa_handler == SIG_DFL
     160                    || SigActOld.sa_handler == rtThreadPosixPokeSignal)
    167161                {
    168                     g_iSigPokeThread = s_aiSigCandidates[iSig];
    169                     break;
     162                    struct sigaction SigAct;
     163                    RT_ZERO(SigAct);
     164                    SigAct.sa_handler = rtThreadPosixPokeSignal;
     165                    SigAct.sa_flags   = 0;
     166                    sigfillset(&SigAct.sa_mask);
     167
     168                    /* ASSUMES no sigaction race... (lazy bird) */
     169                    if (!sigaction(s_aiSigCandidates[iSig], &SigAct, NULL))
     170                    {
     171                        g_iSigPokeThread = s_aiSigCandidates[iSig];
     172                        break;
     173                    }
     174                    AssertMsgFailed(("rc=%Rrc errno=%d\n", RTErrConvertFromErrno(errno), errno));
    170175                }
     176            }
     177            else
    171178                AssertMsgFailed(("rc=%Rrc errno=%d\n", RTErrConvertFromErrno(errno), errno));
    172             }
    173179        }
    174         else
    175             AssertMsgFailed(("rc=%Rrc errno=%d\n", RTErrConvertFromErrno(errno), errno));
    176180    }
    177181#endif /* RTTHREAD_POSIX_WITH_POKE */
     
    231235     * It will not help much if someone creates threads directly using pthread_create. :/
    232236     */
    233     sigset_t SigSet;
    234     sigemptyset(&SigSet);
    235     sigaddset(&SigSet, SIGALRM);
    236     sigprocmask(SIG_BLOCK, &SigSet, NULL);
     237    if (!RTR3InitIsUnobtrusive())
     238    {
     239        sigset_t SigSet;
     240        sigemptyset(&SigSet);
     241        sigaddset(&SigSet, SIGALRM);
     242        sigprocmask(SIG_BLOCK, &SigSet, NULL);
     243    }
    237244#ifdef RTTHREAD_POSIX_WITH_POKE
    238245    if (g_iSigPokeThread != -1)
  • trunk/src/VBox/Runtime/r3/posix/timer-posix.cpp

    r43879 r44456  
    5858#include <iprt/once.h>
    5959#include <iprt/err.h>
     60#include <iprt/initterm.h>
    6061#include <iprt/critsect.h>
    6162#include "internal/magics.h"
     
    405406        return VERR_NOT_SUPPORTED;
    406407
     408    /*
     409     * We need the signal masks to be set correctly, which they won't be in
     410     * unobtrusive mode.
     411     */
     412    if (RTR3InitIsUnobtrusive())
     413        return VERR_NOT_SUPPORTED;
     414
    407415#ifndef IPRT_WITH_POSIX_TIMERS
    408416    /*
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