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 bool Monitor::init() {
27 mFd = epoll_create(16);
29 logg->logMessage("%s(%s:%i): epoll_create1 failed", __FUNCTION__, __FILE__, __LINE__);
36 bool Monitor::add(const int fd) {
37 struct epoll_event event;
38 memset(&event, 0, sizeof(event));
40 event.events = EPOLLIN;
41 if (epoll_ctl(mFd, EPOLL_CTL_ADD, fd, &event) != 0) {
42 logg->logMessage("%s(%s:%i): epoll_ctl failed", __FUNCTION__, __FILE__, __LINE__);
49 int Monitor::wait(struct epoll_event *const events, int maxevents, int timeout) {
50 int result = epoll_wait(mFd, events, maxevents, timeout);
52 // Ignore if the call was interrupted as this will happen when SIGINT is received
56 logg->logMessage("%s(%s:%i): epoll_wait failed", __FUNCTION__, __FILE__, __LINE__);