Use send/sendmsg and don't ignore SIGPIPE

This commit is contained in:
2025-09-13 17:25:20 -04:00
parent cd2e15677a
commit 1fa3381e4b
3 changed files with 7 additions and 5 deletions

View File

@@ -134,7 +134,11 @@ bool Connection::writeBytes() {
ssize_t w;
for (;;) {
w = writev(fd_, iov, iov_count);
struct msghdr msg = {};
msg.msg_iov = iov;
msg.msg_iovlen = iov_count;
w = sendmsg(fd_, &msg, MSG_NOSIGNAL);
if (w == -1) {
if (errno == EINTR) {
continue; // Standard practice: retry on signal interruption
@@ -148,7 +152,7 @@ bool Connection::writeBytes() {
}
return false;
}
perror("writev");
perror("sendmsg");
return true;
}
break;