49 #ifndef QT_NO_SYSTEMSEMAPHORE 51 #include <sys/types.h> 59 #include "private/qcore_unix_p.h" 63 #if defined(Q_OS_OPENBSD) && !defined(EIDRM) 73 unix_key(-1), semaphore(-1), createdFile(false),
75 semaphore(SEM_FAILED),
114 #ifdef QSYSTEMSEMAPHORE_DEBUG 145 createdFile = (1 == built);
149 if (-1 == unix_key) {
156 semaphore = semget(unix_key, 1, 0600 | IPC_CREAT | IPC_EXCL);
159 semaphore = semget(unix_key, 1, 0600 | IPC_CREAT);
166 createdSemaphore =
true;
170 createdSemaphore =
true;
179 if (-1 == semctl(
semaphore, 0, SETVAL, init_op)) {
204 for (
int tryNum = 0, maxTries = 1; tryNum < maxTries; ++tryNum) {
232 createdSemaphore = (oflag &
O_EXCL) != 0;
235 #endif // QT_POSIX_IPC 253 if (createdSemaphore) {
255 if (-1 == semctl(
semaphore, 0, IPC_RMID, 0)) {
257 #ifdef QSYSTEMSEMAPHORE_DEBUG 258 qDebug(
"QSystemSemaphore::cleanHandle semctl failed.");
263 createdSemaphore =
false;
269 #ifdef QSYSTEMSEMAPHORE_DEBUG 276 if (createdSemaphore) {
279 #ifdef QSYSTEMSEMAPHORE_DEBUG 283 createdSemaphore =
false;
285 #endif // QT_POSIX_IPC 297 struct sembuf operation;
298 operation.sem_num = 0;
299 operation.sem_op = count;
300 operation.sem_flg = SEM_UNDO;
313 #ifdef QSYSTEMSEMAPHORE_DEBUG 327 #ifdef QSYSTEMSEMAPHORE_DEBUG 331 for ( ; cnt < count; ++cnt) {
349 #ifdef QSYSTEMSEMAPHORE_DEBUG 355 #endif // QT_POSIX_IPC 362 #endif // QT_NO_SYSTEMSEMAPHORE
void setErrorString(const QString &function)
#define QT_END_NAMESPACE
This macro expands to.
#define EINTR_LOOP(var, cmd)
The QByteArray class provides an array of bytes.
The QSystemSemaphore class provides a general counting system semaphore.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
bool modifySemaphore(int count)
AccessMode
This enum is used by the constructor and setKey().
static int createUnixKeyFile(const QString &fileName)
Creates the unix file if needed.
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QSystemSemaphore::SystemSemaphoreError error
HANDLE handle(QSystemSemaphore::AccessMode mode=QSystemSemaphore::Open)
bool remove()
Removes the file specified by fileName().
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user's loca...
QSystemSemaphorePrivate()