Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qlockfile_p.h
Go to the documentation of this file.
1
// Copyright (C) 2013 David Faure <faure+bluesystems@kde.org>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QLOCKFILE_P_H
6
#
define
QLOCKFILE_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtCore
/
private
/
qglobal_p
.
h
>
20
#
include
<
QtCore
/
qlockfile
.
h
>
21
#
include
<
QtCore
/
qfile
.
h
>
22
23
#
include
<
optional
>
24
25
QT_BEGIN_NAMESPACE
26
27
class
QLockFilePrivate
28
{
29
public
:
30
struct
LockFileInfo
31
{
32
qint64 pid;
33
QString appname;
34
QString hostname;
35
QByteArray hostid;
36
QByteArray bootid;
37
38
QT_DEFINE_TAG_STRUCT(Current);
39
LockFileInfo() =
default
;
40
LockFileInfo(Current);
41
QByteArray asFileContents()
const
;
42
};
43
44
explicit
QLockFilePrivate(
const
QString &fn);
45
~QLockFilePrivate();
46
47
QLockFile::LockError tryLock_sys(
const
LockFileInfo ¤t);
48
bool
removeStaleLock();
49
// Returns \c true if the lock belongs to dead PID, or is old.
50
// The attempt to delete it will tell us if it was really stale or not, though.
51
bool
isApparentlyStale(
const
LockFileInfo ¤t)
const
;
52
53
// used in dbusmenu
54
Q_CORE_EXPORT
static
QString processNameByPid(qint64 pid);
55
static
bool
isProcessRunning(qint64 pid,
const
QString &appname);
56
57
QString fileName;
58
59
static
std::optional<LockFileInfo> getLockInfo_helper(
const
QString &fileName);
60
static
int
openNewFileDescriptor(
const
QString &fileName);
61
62
#
ifdef
Q_OS_WIN
63
Qt::HANDLE fileHandle = Qt::HANDLE(-1);
// INVALID_HANDLE_VALUE
64
#
else
65
int
fileHandle = -1;
66
int
dirHandle = -1;
// the directory where the file is located
67
#
endif
68
69
std::chrono::milliseconds staleLockTime = std::chrono::seconds{30};
70
QLockFile::LockError lockError = QLockFile::NoError;
71
bool
isLocked =
false
;
72
73
// used in tst_QLockFile:
74
static
auto
getLockFileHandle(QLockFile *f)
75
{
76
return
f->d_func()->fileHandle;
77
}
78
};
79
80
QT_END_NAMESPACE
81
82
#
endif
/* QLOCKFILE_P_H */
QLockFile
\inmodule QtCore
Definition
qlockfile.h:19
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
getLockInfo
static std::optional< QLockFilePrivate::LockFileInfo > getLockInfo(int fd)
Definition
qlockfile.cpp:514
machineName
static QString machineName()
Definition
qlockfile.cpp:30
qtbase
src
corelib
io
qlockfile_p.h
Generated on
for Qt by
1.18.0