tty.c: Handle EINVAL and use recommended inotify event size.

The TTY plugin might fail in read() with EINVAL if the inotify event
buffer is too small.  Fix: set the receive event buffer to the size
recommended in inotify(7).  Also add a handler for EINVAL to close and
reinitialize the inotify descriptor so we do not accidentally overrun
the CPU with any unhandled errors.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-10-26 04:33:51 +01:00
1 parent f902505b5d
commit c8f0b97d0f
2 files changed
+10 -3

No files matched your search

+2 -1
View File
@@ -25,9 +25,10 @@
#ifndef FINIT_TTY_H_
#define FINIT_TTY_H_
#include <limits.h>
#include "queue.h" /* BSD sys/queue.h API */
#define EVENT_SIZE ((sizeof(struct inotify_event) + 20))
#define EVENT_SIZE ((sizeof(struct inotify_event) + NAME_MAX + 1))
typedef struct {
char *name;