mirror of https://github.com/ericonr/purr-c.git
Use send with MSG_NOSIGNAL instead of ignoring SIGPIPE.
This commit is contained in:
parent
ee70128300
commit
552388db2d
3
gemi.c
3
gemi.c
|
@ -2,7 +2,6 @@
|
|||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
|
@ -201,8 +200,6 @@ int main(int argc, char **argv)
|
|||
host_connect_error_message();
|
||||
}
|
||||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
FILE *output_stream = stdout;
|
||||
struct pager_proc pager_info;
|
||||
if (pager) {
|
||||
|
|
3
purr.c
3
purr.c
|
@ -1,5 +1,4 @@
|
|||
#define _POSIX_C_SOURCE 200112L /* getopt */
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -277,8 +276,6 @@ int main (int argc, char **argv)
|
|||
host_connect_error_message();
|
||||
goto early_out;
|
||||
}
|
||||
// avoid crashing on socket release
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
const char *alpn = NULL;
|
||||
if (ssl) {
|
||||
|
|
4
socket.c
4
socket.c
|
@ -1,4 +1,6 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "purr.h"
|
||||
|
@ -22,7 +24,7 @@ int socket_write(void *ctx, const uint8_t *buf, size_t len)
|
|||
{
|
||||
int fd = *(int *)ctx;
|
||||
while (1) {
|
||||
ssize_t wlen = write(fd, buf, len);
|
||||
ssize_t wlen = send(fd, buf, len, MSG_NOSIGNAL);
|
||||
if (wlen <= 0) {
|
||||
if (wlen < 0 && errno == EINTR) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue