summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index e034a6a0..3cb42140 100644
--- a/monitor.c
+++ b/monitor.c
@@ -38,8 +38,17 @@ static int write_attr(char *attr, int fd)
static void add_fd(fd_set *fds, int *maxfd, int fd)
{
+ struct stat st;
if (fd < 0)
return;
+ if (fstat(fd, &st) == -1) {
+ dprintf("%s: Invalid fd %d\n", __func__, fd);
+ return;
+ }
+ if (st.st_nlink == 0) {
+ dprintf("%s: fd %d was deleted\n", __func__, fd);
+ return;
+ }
if (fd > *maxfd)
*maxfd = fd;
FD_SET(fd, fds);