2 * Copyright (C) ARM Limited 2013-2014. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
17 Monitor::Monitor() : mFd(-1) {
26 void Monitor::close() {
33 bool Monitor::init() {
34 mFd = epoll_create(16);
36 logg->logMessage("%s(%s:%i): epoll_create1 failed", __FUNCTION__, __FILE__, __LINE__);
43 bool Monitor::add(const int fd) {
44 struct epoll_event event;
45 memset(&event, 0, sizeof(event));
47 event.events = EPOLLIN;
48 if (epoll_ctl(mFd, EPOLL_CTL_ADD, fd, &event) != 0) {
49 logg->logMessage("%s(%s:%i): epoll_ctl failed", __FUNCTION__, __FILE__, __LINE__);
56 int Monitor::wait(struct epoll_event *const events, int maxevents, int timeout) {
57 int result = epoll_wait(mFd, events, maxevents, timeout);
59 // Ignore if the call was interrupted as this will happen when SIGINT is received
63 logg->logMessage("%s(%s:%i): epoll_wait failed", __FUNCTION__, __FILE__, __LINE__);