Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions libctru/source/services/soc/soc_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
memcpy(tmp_fds, fds, sizeof(struct pollfd) * nfds);

for(i = 0; i < nfds; ++i) {
tmp_fds[i].fd = soc_get_fd(fds[i].fd);
if(tmp_fds[i].fd < 0) {
errno = -tmp_fds[i].fd;
free(tmp_fds);
return -1;
if (fds[i].fd >= 0) {
tmp_fds[i].fd = soc_get_fd(fds[i].fd);
if(tmp_fds[i].fd < 0) {
errno = -tmp_fds[i].fd;
free(tmp_fds);
return -1;
}
}
// negative fds are ignored, however 3ds poll only
// ignores fd's that are -1.
// this forces negative fds to -1 so they are ignored without error.
else {
tmp_fds[i].fd = -1;
}
tmp_fds[i].revents = 0;
}
Expand Down