commit c4f556d850b4e2f0879a3e930b813251d21c8499
parent 01f4e171f54a0420cbecbcfe2099719a28c5bee8
Author: sin <sin@2f30.org>
Date: Fri, 3 Jun 2016 09:59:12 +0100
Restart read(2) on EINTR
This can happen because of a SIGWINCH signal.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ncmixer.c b/ncmixer.c
@@ -201,7 +201,9 @@ ch0_cb(int fd)
int n;
memset(ch0_buf, 0, sizeof(ch0_buf));
- n = read(fd, ch0_buf, sizeof(ch0_buf));
+ do {
+ n = read(fd, ch0_buf, sizeof(ch0_buf));
+ } while (n == -1 && errno == EINTR);
if (n == 0 || n == -1)
return -1;
ch0_nsamples = n / 2;
@@ -214,7 +216,9 @@ ch1_cb(int fd)
int n;
memset(ch1_buf, 0, sizeof(ch1_buf));
- n = read(fd, ch1_buf, sizeof(ch1_buf));
+ do {
+ n = read(fd, ch1_buf, sizeof(ch1_buf));
+ } while (n == -1 && errno == EINTR);
if (n == 0 || n == -1)
return -1;
ch1_nsamples = n / 2;