VirtualBox

Changeset 30392 in vbox for trunk


Ignore:
Timestamp:
Jun 23, 2010 1:37:14 PM (15 years ago)
Author:
vboxsync
Message:

VBoxGuestR3Lib.cpp: Mask all unimportant signals before doing the ioctl call on solaris (X11 drivers are excluded). This is untested code which attempts to work around the SIGCHLD problem in #5068.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp

    r28800 r30392  
    55
    66/*
    7  * Copyright (C) 2007 Oracle Corporation
     7 * Copyright (C) 2007-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4444# if defined(RT_OS_LINUX) /** @todo check this on solaris+freebsd as well. */
    4545#  include <sys/ioctl.h>
     46# endif
     47# if defined(RT_OS_SOLARIS) && !defined(VBOX_VBGLR3_XFREE86)
     48#  define VBGL_DO_MASK_SIGNALS
     49#  include <signal.h>
    4650# endif
    4751# include <errno.h>
     
    289293
    290294
     295/*
     296 * Helper macros for blocking and restoring signals.
     297 */
     298#ifdef VBGL_DO_MASK_SIGNALS
     299# define BLOCK_SIGNALS(Prf) \
     300    int         Prf##_rcSig; \
     301    sigset_t    Prf##_SigSetOld; \
     302    do \
     303    { \
     304        sigset_t Prf##_SigSetNew; \
     305        sigfillset(& Prf##_SigSetNew); \
     306        sigdelset(& Prf##_SigSetNew, SIGTERM); \
     307        sigdelset(& Prf##_SigSetNew, SIGINT); \
     308        sigdelset(& Prf##_SigSetNew, SIGHUP); \
     309        sigdelset(& Prf##_SigSetNew, SIGABRT); \
     310        sigdelset(& Prf##_SigSetNew, SIGKILL); \
     311        Prf##_rcSig = pthread_sigmask(SIG_BLOCK, & Prf##_SigSetNew, & Prf##_SigSetOld); \
     312    } while (0)
     313
     314# define RESTORE_SIGNALS(Prf) \
     315    do \
     316    { \
     317        if (Prf##_rcSig == 0) \
     318        { \
     319            int Prf##_err = errno; /* paranoia */ \
     320            pthread_sigmask(SIG_SETMASK, & Prf##_SigSetOld, NULL); \
     321            errno = Prf##_err; \
     322        } \
     323    } while (0)
     324
     325#else
     326# define BLOCK_SIGNALS(Prf)     do { } while (0)
     327# define RESTORE_SIGNALS(Prf)   do { } while (0)
     328#endif
     329
     330
    291331/**
    292332 * Internal wrapper around various OS specific ioctl implemenations.
     
    345385 *        header with an error code return field (much better alternative
    346386 *        actually). */
     387    BLOCK_SIGNALS(SigPrefix);
    347388    int rc = ioctl((int)g_File, iFunction, &Hdr);
     389    RESTORE_SIGNALS(SigPrefix);
    348390    if (rc == -1)
    349391    {
     
    354396
    355397#elif defined(RT_OS_LINUX)
     398    BLOCK_SIGNALS(SigPrefix);
    356399# ifdef VBOX_VBGLR3_XFREE86
    357400    int rc = xf86ioctl((int)g_File, iFunction, pvData);
     
    359402    int rc = ioctl((int)g_File, iFunction, pvData);
    360403# endif
     404    RESTORE_SIGNALS(SigPrefix);
    361405    if (RT_LIKELY(rc == 0))
    362406        return VINF_SUCCESS;
     
    377421    /* PORTME - This is preferred over the RTFileIOCtl variant below, just be careful with the (int). */
    378422/** @todo test status code passing! */
     423    BLOCK_SIGNALS(SigPrefix);
    379424    int rc = xf86ioctl(g_File, iFunction, pvData);
     425    RESTORE_SIGNALS(SigPrefix);
    380426    if (rc == -1)
    381427        return VERR_FILE_IO_ERROR;  /* This is purely legacy stuff, it has to work and no more. */
     
    385431    /* Default implementation - PORTME: Do not use this without testings that passing errors works! */
    386432/** @todo test status code passing! */
     433    BLOCK_SIGNALS(SigPrefix);
    387434    int rc2 = VERR_INTERNAL_ERROR;
    388435    int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2);
     436    RESTORE_SIGNALS(SigPrefix);
    389437    if (RT_SUCCESS(rc))
    390438        rc = rc2;
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