amidi, aseqnet: handle write errors

BugLink: https://github.com/alsa-project/alsa-utils/issues/17
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-03-05 21:50:28 +01:00
parent ade71cf8b0
commit f8ce4f1e3a
2 changed files with 10 additions and 4 deletions

View file

@ -688,8 +688,11 @@ int main(int argc, char *argv[])
continue;
read += length;
if (receive_file != -1)
write(receive_file, buf, length);
if (receive_file != -1) {
ssize_t wlength = write(receive_file, buf, length);
if (wlength != length)
error("write error: %s", wlength < 0 ? strerror(errno) : "short");
}
if (dump) {
for (i = 0; i < length; ++i)
print_byte(buf[i]);

View file

@ -491,8 +491,11 @@ static void flush_writebuf(void)
if (cur_wrlen) {
int i;
for (i = 0; i < max_connection; i++) {
if (netfd[i] >= 0)
write(netfd[i], writebuf, cur_wrlen);
if (netfd[i] >= 0) {
ssize_t wrlen = write(netfd[i], writebuf, cur_wrlen);
if (wrlen != (ssize_t)cur_wrlen)
fprintf(stderr, "write error: %s", wrlen < 0 ? strerror(errno) : "short");
}
}
cur_wrlen = 0;
}