Removed undefined behaviour by using `poll` over `select`.
This commit is contained in:
parent
6229f74ccd
commit
0315d397bd
|
@ -1,8 +1,8 @@
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
#include <sys/select.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
|
|
||||||
struct dirmonitor_internal {
|
struct dirmonitor_internal {
|
||||||
|
@ -30,11 +30,8 @@ void deinit_dirmonitor(struct dirmonitor_internal* monitor) {
|
||||||
|
|
||||||
|
|
||||||
int get_changes_dirmonitor(struct dirmonitor_internal* monitor, char* buffer, int length) {
|
int get_changes_dirmonitor(struct dirmonitor_internal* monitor, char* buffer, int length) {
|
||||||
fd_set set;
|
struct pollfd fds[2] = { { .fd = monitor->fd, .events = POLLIN | POLLERR, .revents = 0 }, { .fd = monitor->sig[0], .events = POLLIN | POLLERR, .revents = 0 } };
|
||||||
FD_ZERO(&set);
|
poll(fds, 2, -1);
|
||||||
FD_SET(monitor->fd, &set);
|
|
||||||
FD_SET(monitor->sig[0], &set);
|
|
||||||
select(FD_SETSIZE, &set, NULL, NULL, NULL);
|
|
||||||
return read(monitor->fd, buffer, length);
|
return read(monitor->fd, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue