QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate() { extern Qt::HANDLE qt_application_thread_id; mainThread = (QThread::currentThreadId() == qt_application_thread_id); bool pipefail = false; // initialize the common parts of the event loop #if defined(Q_OS_NACL) || defined (Q_OS_BLACKBERRY) // do nothing. #elif defined(Q_OS_INTEGRITY) // INTEGRITY doesn't like a "select" on pipes, so use socketpair instead if (socketpair(AF_INET, SOCK_STREAM, 0, thread_pipe) == -1) { perror("QEventDispatcherUNIXPrivate(): Unable to create socket pair"); pipefail = true; } else { initThreadPipeFD(thread_pipe[0]); initThreadPipeFD(thread_pipe[1]); } #elif defined(Q_OS_VXWORKS) char name[20]; qsnprintf(name, sizeof(name), "/pipe/qt_%08x", int(taskIdSelf())); // make sure there is no pipe with this name pipeDevDelete(name, true); // create the pipe if (pipeDevCreate(name, 128 /*maxMsg*/, 1 /*maxLength*/) != OK) { perror("QEventDispatcherUNIXPrivate(): Unable to create thread pipe device"); pipefail = true; } else { if ((thread_pipe[0] = open(name, O_RDWR, 0)) < 0) { perror("QEventDispatcherUNIXPrivate(): Unable to create thread pipe"); pipefail = true; } else { initThreadPipeFD(thread_pipe[0]); thread_pipe[1] = thread_pipe[0]; } } #else # ifndef QT_NO_EVENTFD thread_pipe[0] = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); if (thread_pipe[0] != -1) thread_pipe[1] = -1; else // fall through the next "if" # endif if (qt_safe_pipe(thread_pipe, O_NONBLOCK) == -1) { perror("QEventDispatcherUNIXPrivate(): Unable to create thread pipe"); pipefail = true; } #endif if (pipefail) qFatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe"); sn_highest = -1; }
static int qt_create_pipe(int *pipe) { if (pipe[0] != -1) qt_safe_close(pipe[0]); if (pipe[1] != -1) qt_safe_close(pipe[1]); int pipe_ret = qt_safe_pipe(pipe); if (pipe_ret != 0) { qWarning("QProcessPrivate::createPipe: Cannot create pipe %p: %s", pipe, qPrintable(qt_error_string(errno))); } return pipe_ret; }
QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate() { extern Qt::HANDLE qt_application_thread_id; mainThread = (QThread::currentThreadId() == qt_application_thread_id); // initialize the common parts of the event loop if (qt_safe_pipe(thread_pipe, O_NONBLOCK) == -1) { perror("QEventDispatcherUNIXPrivate(): Unable to create thread pipe"); qFatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe"); } sn_highest = -1; interrupt = false; }
QDnotifySignalThread::QDnotifySignalThread() : isExecing(false) { moveToThread(this); qt_safe_pipe(qfswd_fileChanged_pipe, O_NONBLOCK); struct sigaction oldAction; struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_sigaction = qfswd_sigio_monitor; action.sa_flags = SA_SIGINFO; ::sigaction(SIGIO, &action, &oldAction); if (!(oldAction.sa_flags & SA_SIGINFO)) qfswd_old_sigio_handler = oldAction.sa_handler; else qfswd_old_sigio_action = oldAction.sa_sigaction; }