childStartedPipe[0]);
#endif
- fd_set fds;
- FD_ZERO(&fds);
- FD_SET(childStartedPipe[0], &fds);
- if (select_msecs(childStartedPipe[0] + 1, &fds, 0, msecs) == 0) {
+ struct pollfd fds;
+ ::memset(&fds, 0, sizeof(struct pollfd));
+ fds.fd = childStartedPipe[0];
+ fds.events = POLLIN;
+ if (qt_safe_poll(&fds, 1, msecs) == 0) {
processError = QProcess::Timedout;
q->setErrorString(QProcess::tr("Process operation timed out"));
#if defined (QPROCESS_DEBUG)
}
// don't call ::poll, call qt_safe_poll
-static inline int qt_safe_poll(int fd, int events, int timeout, int *revents)
+static inline int qt_safe_poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
- struct pollfd pd;
- ::memset(&pd, 0, sizeof(struct pollfd));
- pd.fd = fd;
- pd.events = events;
int ret;
- Q_EINTR_LOOP(ret, ::poll(&pd, 1, timeout));
- if ((pd.revents & POLLERR) != 0 || (pd.revents & POLLHUP) != 0 || (pd.revents & POLLNVAL) != 0) {
+ Q_EINTR_LOOP(ret, ::poll(fds, nfds, timeout));
+ if ((fds->revents & POLLERR) != 0 || (fds->revents & POLLHUP) != 0 || (fds->revents & POLLNVAL) != 0) {
// select() compat
return -1;
}
- *revents = pd.revents;
return ret;
}
void QLocalServerPrivate::waitForNewConnection(int msec, bool *timedOut)
{
- int revents = 0;
- int result = qt_safe_poll(listenSocket, POLLIN, msec, &revents);
+ struct pollfd fds;
+ ::memset(&fds, 0, sizeof(struct pollfd));
+ fds.fd = listenSocket;
+ fds.events = POLLIN;
+ int result = qt_safe_poll(&fds, 1, msec);
if (result == -1) {
setError(QLatin1String("QLocalServer::waitForNewConnection"));
closeServer();
if (msec == 0)
msec = 1000;
- int revents = 0;
- int result = qt_safe_poll(d->connectingSocket, POLLIN, msec, &revents);
+ struct pollfd fds;
+ ::memset(&fds, 0, sizeof(struct pollfd));
+ fds.fd = d->connectingSocket;
+ fds.events = POLLIN;
+ int result = qt_safe_poll(&fds, 1, msec);
if (result == -1) {
d->errorOccurred( QLocalSocket::UnknownSocketError,
QLatin1String("QLocalSocket::waitForConnected"));
int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) const
{
- int revents = 0;
- return qt_safe_poll(socketDescriptor, selectForRead ? POLLIN : POLLOUT, timeout, &revents);
+ struct pollfd fds;
+ ::memset(&fds, 0, sizeof(struct pollfd));
+ fds.fd = socketDescriptor;
+ fds.events = (selectForRead ? POLLIN : POLLOUT);
+ return qt_safe_poll(&fds, 1, timeout);
}
int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool checkWrite,
bool *selectForRead, bool *selectForWrite) const
{
- int events = 0;
+ struct pollfd fds;
+ ::memset(&fds, 0, sizeof(struct pollfd));
+ fds.fd = socketDescriptor;
+ fds.events = 0;
if (checkRead) {
- events |= POLLIN;
+ fds.events |= POLLIN;
}
if (checkWrite) {
- events |= POLLOUT;
+ fds.events |= POLLOUT;
}
- int revents = 0;
- int ret = qt_safe_poll(socketDescriptor, events, timeout, &revents);
+ int ret = qt_safe_poll(&fds, 1, timeout);
if (ret > 0) {
- *selectForRead = ((revents & POLLIN) != 0);
- *selectForWrite = ((revents & POLLOUT) != 0);
+ *selectForRead = ((fds.revents & POLLIN) != 0);
+ *selectForWrite = ((fds.revents & POLLOUT) != 0);
}
return ret;
}