VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp

Last change on this file was 100064, checked in by vboxsync, 12 months ago

FE/Qt: bugref:10421. Replacing VBOX_WS_X11 with VBOX_WS_NIX.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp79224,​79228,​79233,​79235,​79258,​79262-79263,​79273,​79341,​79345,​79354,​79357,​79387-79388,​79559-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VirtualBox/src/extensions/QIProcess.cpp79645-79692
File size: 2.3 KB
Line 
1/* $Id: QIProcess.cpp 100064 2023-06-04 09:10:01Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QIProcess class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* GUI includes: */
29#include "QIProcess.h"
30
31/* External includes: */
32#ifdef VBOX_WS_NIX
33# include <sys/wait.h>
34#endif
35
36
37QIProcess::QIProcess(QObject *pParent /* = 0 */)
38 : QProcess(pParent)
39{
40}
41
42/* static */
43QByteArray QIProcess::singleShot(const QString &strProcessName, int iTimeout /* = 5000 */)
44{
45 // WORKAROUND:
46 // Why is it really needed is because of Qt4.3 bug with QProcess.
47 // This bug is about QProcess sometimes (~70%) do not receive
48 // notification about process was finished, so this makes
49 // 'bool QProcess::waitForFinished (int)' block the GUI thread and
50 // never dismissed with 'true' result even if process was really
51 // started&finished. So we just waiting for some information
52 // on process output and destroy the process with force. Due to
53 // QProcess::~QProcess() has the same 'waitForFinished (int)' blocker
54 // we have to change process state to QProcess::NotRunning.
55
56 /// @todo Do we still need this?
57 QByteArray result;
58 QIProcess process;
59 process.start(strProcessName);
60 bool firstShotReady = process.waitForReadyRead(iTimeout);
61 if (firstShotReady)
62 result = process.readAllStandardOutput();
63 process.setProcessState(QProcess::NotRunning);
64#ifdef VBOX_WS_NIX
65 int iStatus;
66 if (process.processId() > 0)
67 waitpid(process.processId(), &iStatus, 0);
68#endif /* VBOX_WS_NIX */
69 return result;
70}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use