VirtualBox

Changeset 35520 in vbox


Ignore:
Timestamp:
Jan 13, 2011 11:01:44 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
69404
Message:

FE/Qt4: make it possible to create a pidfile when a VM is up and running

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r35423 r35520  
    6565#include <QHelpEvent>
    6666#include <QLocale>
     67
     68#ifdef VBOX_WITH_PIDFILE
     69# include <QTextStream>
     70#endif /* VBOX_WITH_PIDFILE */
    6771
    6872#include <math.h>
     
    444448    return m_pVirtualMachine;
    445449}
     450
     451#ifdef VBOX_WITH_PIDFILE
     452void VBoxGlobal::createPidfile()
     453{
     454    if (!m_strPidfile.isEmpty())
     455    {
     456        qint64 pid = qApp->applicationPid();
     457        QFile file(m_strPidfile);
     458        if (file.open(QIODevice::WriteOnly | QIODevice::Truncate))
     459        {
     460             QTextStream out(&file);
     461             out << pid << endl;
     462        }
     463        else
     464            LogRel(("Failed to create pid file %s\n", m_strPidfile.toUtf8().constData()));
     465    }
     466}
     467
     468void VBoxGlobal::deletePidfile()
     469{
     470    if (   !m_strPidfile.isEmpty()
     471        && QFile::exists(m_strPidfile))
     472        QFile::remove(m_strPidfile);
     473}
     474#endif
    446475
    447476bool VBoxGlobal::brandingIsActive (bool aForce /* = false*/)
     
    50065035            }
    50075036        }
     5037#ifdef VBOX_WITH_PIDFILE
     5038        else if (!::strcmp(arg, "-pidfile") || !::strcmp(arg, "--pidfile"))
     5039        {
     5040            if (++i < argc)
     5041                m_strPidfile = QString(qApp->argv()[i]);
     5042        }
     5043#endif /* VBOX_WITH_PIDFILE */
    50085044        else if (!::strcmp(arg, "-seamless") || !::strcmp(arg, "--seamless"))
    50095045        {
     
    51725208        }
    51735209    }
     5210#endif
     5211
     5212#ifdef VBOX_WITH_PIDFILE
     5213    deletePidfile();
    51745214#endif
    51755215
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r35423 r35520  
    147147    QWidget *mainWindow() const { return mMainWindow; }
    148148
     149#ifdef VBOX_WITH_PIDFILE
     150    void createPidfile();
     151    void deletePidfile();
     152#endif
     153
    149154    /* branding */
    150155    bool brandingIsActive (bool aForce = false);
     
    863868    QFileIconProvider m_globalIconProvider;
    864869
     870#ifdef VBOX_WITH_PIDFILE
     871    QString m_strPidfile;
     872#endif
     873
    865874    friend VBoxGlobal &vboxGlobal();
    866875};
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r34623 r35520  
    260260            "  --rmode %-18s select different render mode (default is %s)\n"
    261261            "  --no-startvm-errormsgbox   do not show a message box for VM start errors\n"
     262# ifdef VBOX_WITH_PIDFILE
     263            "  --pid-file file            create a pidfile file when a VM is up and running\n"
     264# endif
    262265# ifdef VBOX_WITH_DEBUGGER_GUI
    263266            "  --dbg                      enable the GUI debug menu\n"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r35141 r35520  
    282282#endif
    283283
     284#ifdef VBOX_WITH_PIDFILE
     285    vboxGlobal().createPidfile();
     286#endif
     287
    284288    /* Warn listeners about machine was started: */
    285289    emit sigMachineStarted();
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