fix: use send instead of write to prevent SIGPIPE
parent
a96ae39523
commit
64601b5f21
|
@ -1,6 +1,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "lnm/loop.h"
|
#include "lnm/loop.h"
|
||||||
#include "lnm/loop_internal.h"
|
#include "lnm/loop_internal.h"
|
||||||
|
@ -43,7 +44,9 @@ void lnm_loop_conn_io_res(lnm_loop *l, lnm_loop_conn *conn) {
|
||||||
ssize_t res;
|
ssize_t res;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
res = write(conn->fd, conn->w.buf, conn->w.size);
|
// Send with MSG_NOSIGNAL prevents closed pipes from exiting the program
|
||||||
|
// with SIGPIPE
|
||||||
|
res = send(conn->fd, conn->w.buf, conn->w.size, MSG_NOSIGNAL);
|
||||||
} while (res < 0 && errno == EINTR);
|
} while (res < 0 && errno == EINTR);
|
||||||
|
|
||||||
// Write can't be performed without blocking; we come back later
|
// Write can't be performed without blocking; we come back later
|
||||||
|
|
Loading…
Reference in New Issue