Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
stdinlistener_win.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
5
6#include "tracer.h"
7
9
12{
14}
15
16StdInListener::~StdInListener()
17{
19 terminate();
20 wait();
21}
22
23void StdInListener::run()
24{
26 bool ok = true;
27 char chBuf[4096];
28 DWORD dwRead;
29 HANDLE hStdinDup;
30
31 const HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
32 if (hStdin == INVALID_HANDLE_VALUE)
33 return;
34
35 DuplicateHandle(GetCurrentProcess(), hStdin,
36 GetCurrentProcess(), &hStdinDup,
37 0, false, DUPLICATE_SAME_ACCESS);
38
39 CloseHandle(hStdin);
40
41 while (ok) {
42 ok = ReadFile(hStdinDup, chBuf, sizeof(chBuf), &dwRead, NULL);
43 if (ok && dwRead != 0)
44 emit receivedCommand(QString::fromLocal8Bit(chBuf, dwRead));
45 }
46}
47
48QT_END_NAMESPACE
QObject * parent
Definition qobject.h:73
\inmodule QtCore
Definition qobject.h:103
Combined button and popup list for selecting options.
#define TRACE_OBJ
Definition tracer.h:34