diff --git a/monitor.c b/monitor.c
index a0e3ffb..34a968c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2304,7 +2304,8 @@ int monitor_fdset_get_fd(int64_t fdset_id, int flags)
                 return -1;
             }
 
-            if ((flags & O_ACCMODE) == (mon_fd_flags & O_ACCMODE)) {
+            if ((mon_fd_flags & O_ACCMODE) == O_RDWR ||
+                (mon_fd_flags & O_ACCMODE) == (flags & O_ACCMODE)) {
                 return mon_fdset_fd->fd;
             }
         }
