VirtualBox

Changeset 89907 in vbox


Ignore:
Timestamp:
Jun 24, 2021 11:23:21 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145365
Message:

FE/VBoxHeadless: Enable signal handlers on all unix platforms. Note
in the function's comment for showProgress() that we don't check for
signals in b/c the power up/down operations are not cancelable anyway.
Establish the signal handlers earlier. Add a todo item to convert any
temporary changes we do to the settings to use RAII so that they are
undone automatically. bugref:8161.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r89222 r89907  
    5858#endif
    5959
    60 //#define VBOX_WITH_SAVESTATE_ON_SIGNAL
    61 #ifdef VBOX_WITH_SAVESTATE_ON_SIGNAL
     60#if !defined(RT_OS_WINDOWS)
    6261#include <signal.h>
    6362static void HandleSignal(int sig);
     
    396395VBOX_LISTENER_DECLARE(ConsoleEventListenerImpl)
    397396
    398 #ifdef VBOX_WITH_SAVESTATE_ON_SIGNAL
     397#if !defined(RT_OS_WINDOWS)
    399398static void
    400399HandleSignal(int sig)
     
    404403    g_fTerminateFE = true;
    405404}
    406 #endif /* VBOX_WITH_SAVESTATE_ON_SIGNAL */
     405#endif /* !RT_OS_WINDOWS */
    407406
    408407////////////////////////////////////////////////////////////////////////////////
     
    983982/*
    984983 * Simplified version of showProgress() borrowed from VBoxManage.
     984 * Note that machine power up/down operations are not cancelable, so
     985 * we don't bother checking for signals.
    985986 */
    986987HRESULT
     
    16231624        Log(("VBoxHeadless: Powering up the machine...\n"));
    16241625
    1625         ComPtr <IProgress> progress;
    1626         if (!fPaused)
    1627             CHECK_ERROR_BREAK(console, PowerUp(progress.asOutParam()));
    1628         else
    1629             CHECK_ERROR_BREAK(console, PowerUpPaused(progress.asOutParam()));
    1630 
    1631         rc = showProgress(progress);
    1632         if (FAILED(rc))
    1633         {
    1634             com::ProgressErrorInfo info(progress);
    1635             if (info.isBasicAvailable())
    1636             {
    1637                 RTPrintf("Error: failed to start machine. Error message: %ls\n", info.getText().raw());
    1638             }
    1639             else
    1640             {
    1641                 RTPrintf("Error: failed to start machine. No error message available!\n");
    1642             }
    1643             break;
    1644         }
    1645 
    1646 #ifdef VBOX_WITH_SAVESTATE_ON_SIGNAL
     1626
     1627        /**
     1628         * @todo We should probably install handlers earlier so that
     1629         * we can undo any temporary settings we do above in case of
     1630         * an early signal and use RAII to ensure proper cleanup.
     1631         */
     1632#if !defined(RT_OS_WINDOWS)
    16471633        signal(SIGPIPE, SIG_IGN);
    16481634        signal(SIGTTOU, SIG_IGN);
     
    16561642        sigaction(SIGUSR1, &sa, NULL);
    16571643        sigaction(SIGUSR2, &sa, NULL);
    1658 #endif
    1659 
    1660 #ifdef RT_OS_WINDOWS
     1644#else /* RT_OS_WINDOWS */
    16611645        /*
    16621646         * Register windows console signal handler to react to Ctrl-C,
    1663          * Ctrl-Break, Close.
     1647         * Ctrl-Break, Close, non-interactive session termination.
    16641648         */
    16651649        ::SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
    1666 
     1650#endif
     1651
     1652
     1653        ComPtr <IProgress> progress;
     1654        if (!fPaused)
     1655            CHECK_ERROR_BREAK(console, PowerUp(progress.asOutParam()));
     1656        else
     1657            CHECK_ERROR_BREAK(console, PowerUpPaused(progress.asOutParam()));
     1658
     1659        rc = showProgress(progress);
     1660        if (FAILED(rc))
     1661        {
     1662            com::ProgressErrorInfo info(progress);
     1663            if (info.isBasicAvailable())
     1664            {
     1665                RTPrintf("Error: failed to start machine. Error message: %ls\n", info.getText().raw());
     1666            }
     1667            else
     1668            {
     1669                RTPrintf("Error: failed to start machine. No error message available!\n");
     1670            }
     1671            break;
     1672        }
     1673
     1674#ifdef RT_OS_WINDOWS
    16671675        /*
    16681676         * Spawn windows message pump to monitor session events.
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