diff options
author | wm4 <wm4@nowhere> | 2013-10-28 23:32:57 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-02 19:05:04 +0100 |
commit | 0ba37607451da7b85b295e68c7824bb73b631b48 (patch) | |
tree | 78ba3523cd69304a42f12215fa00fe181abe370d /osdep | |
parent | 1dbbd845a47a0008b79f99dced9a778189f9fd79 (diff) | |
download | mpv-0ba37607451da7b85b295e68c7824bb73b631b48.tar.bz2 mpv-0ba37607451da7b85b295e68c7824bb73b631b48.tar.xz |
getch2: assume EOF when input file descriptor is invalid
When starting mpv with nohup, file descriptor 0 seems to be invalid for
some reason. (I'm not quite sure why it should be... /proc/pid/fd/0
seems to indicate it's just /dev/null, and using /dev/null explicitly
shows that it works just fine.)
select() will always immediately return, and this causes mpv to burn CPU
without reason. Fix this by treating it as EOF when read() returns
EBADF.
Also add EINVAL to this condition, because it seems like a good idea.
Conflicts:
osdep/getch2.c
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/getch2.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/osdep/getch2.c b/osdep/getch2.c index eeefa8c9e6..ba474ea51a 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -34,6 +34,7 @@ #ifdef CONFIG_IOCTL #include <sys/ioctl.h> #endif +#include <errno.h> #ifdef HAVE_TERMIOS #ifdef HAVE_TERMIOS_H @@ -369,8 +370,10 @@ bool getch2(struct input_ctx *input_ctx) * happen if the terminal state change done in getch2_enable() * works. */ - if (retval < 1) - return retval; + if (retval == 0) + return false; + if (retval == -1) + return errno != EBADF && errno != EINVAL; getch2_len += retval; static enum { |