VirtualBox

Changeset 10501 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 11, 2008 9:29:38 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
33180
Message:

FE/SDL: added (undocumented) -pidfile parameter

Location:
trunk/src/VBox/Frontends/VBoxSDL
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp

    r8155 r10501  
    4242#include <VBox/err.h>
    4343#include <VBox/log.h>
    44 #include <signal.h>
    4544
    4645#include "VBoxSDL.h"
     
    145144        return;
    146145    }
    147 
    148 #ifdef VBOXSDL_WITH_X11
    149     /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
    150     signal(SIGINT, SIG_DFL);
    151     signal(SIGQUIT, SIG_DFL);
    152 #endif
    153146
    154147    const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r10434 r10501  
    164164#endif
    165165static const char *gHostKeyDisabledCombinations = "";
     166static const char *gpszPidFile;
    166167static BOOL gfGrabbed = FALSE;
    167168static BOOL gfGrabOnMouseClick = TRUE;
     
    743744 * annoying enough for introducing this hack.
    744745 */
    745 void signal_handler(int sig, siginfo_t *info, void *secret)
     746void signal_handler_SIGUSR1(int sig, siginfo_t *info, void *secret)
    746747{
    747748    /* only SIGUSR1 is interesting */
     
    751752        ResetKeys();
    752753    }
     754}
     755
     756/**
     757 * Custom signal handler for catching exit events.
     758 */
     759void signal_handler_SIGINT(int sig)
     760{
     761    if (gpszPidFile)
     762        RTFileDelete(gpszPidFile);
     763    signal(SIGINT, SIG_DFL);
     764    signal(SIGQUIT, SIG_DFL);
     765    signal(SIGSEGV, SIG_DFL);
     766    kill(getpid(), sig);
    753767}
    754768#endif /* VBOXSDL_WITH_X11 */
     
    13261340            gfACPITerm = TRUE;
    13271341        }
     1342        else if (strcmp(argv[curArg], "-pidfile") == 0)
     1343        {
     1344            if (++curArg >= argc)
     1345            {
     1346                RTPrintf("Error: missing file name for -pidfile!\n");
     1347                rc = E_FAIL;
     1348                break;
     1349            }
     1350            gpszPidFile = argv[curArg];
     1351        }
    13281352        else if (strcmp(argv[curArg], "-hda") == 0)
    13291353        {
     
    19021926    gpFrameBuffer->AddRef();
    19031927    if (fFullscreen)
    1904     {
    19051928        gpFrameBuffer->setFullscreen(true);
    1906     }
     1929
    19071930#ifdef VBOX_SECURELABEL
    19081931    if (fSecureLabel)
     
    19511974        gpFrameBuffer->setSecureLabelText(labelUtf8.raw());
    19521975    }
     1976#endif
     1977
     1978#ifdef VBOXSDL_WITH_X11
     1979    /* NOTE1: We still want Ctrl-C to work, so we undo the SDL redirections.
     1980     * NOTE2: We have to remove the PidFile if this file exists. */
     1981    signal(SIGINT,  signal_handler_SIGINT);
     1982    signal(SIGQUIT, signal_handler_SIGINT);
     1983    signal(SIGSEGV, signal_handler_SIGINT);
    19531984#endif
    19541985
     
    21302161#ifdef VBOXSDL_WITH_X11
    21312162    struct sigaction sa;
    2132     sa.sa_sigaction = signal_handler;
     2163    sa.sa_sigaction = signal_handler_SIGUSR1;
    21332164    sigemptyset (&sa.sa_mask);
    21342165    sa.sa_flags = SA_RESTART | SA_SIGINFO;
     
    23192350     */
    23202351    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
     2352
     2353    /*
     2354     * Create PID file.
     2355     */
     2356    if (gpszPidFile)
     2357    {
     2358        char szBuf[32];
     2359        const char *pcszLf = "\n";
     2360        RTFILE PidFile;
     2361        RTFileOpen(&PidFile, gpszPidFile, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE);
     2362        RTStrFormatNumber(szBuf, RTProcSelf(), 10, 0, 0, 0);
     2363        RTFileWrite(PidFile, szBuf, strlen(szBuf), NULL);
     2364        RTFileWrite(PidFile, pcszLf, strlen(pcszLf), NULL);
     2365        RTFileClose(PidFile);
     2366    }
    23212367
    23222368    /*
     
    27192765
    27202766leave:
     2767    if (gpszPidFile)
     2768        RTFileDelete(gpszPidFile);
     2769
    27212770    LogFlow(("leaving...\n"));
    27222771#if defined(VBOX_WITH_XPCOM) && !defined(RT_OS_DARWIN) && !defined(RT_OS_OS2)
Note: See TracChangeset for help on using the changeset viewer.

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