mirror of
https://github.com/openbsd/src.git
synced 2024-12-22 07:27:59 -08:00
Kill the SIGPIPE signal handler which is installed around write opertations.
Instead just SIG_IGN SIGPIPE in main.c for all of acme-client. More work to be done here but at least this distraction is gone. OK florian@ deraadt@ op@
This commit is contained in:
parent
3bbea653b9
commit
d7c05bd5f8
@ -1,4 +1,4 @@
|
||||
/* $Id: main.c,v 1.55 2022/05/05 19:51:35 florian Exp $ */
|
||||
/* $Id: main.c,v 1.56 2024/06/19 13:13:25 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
@ -21,6 +21,7 @@
|
||||
#include <err.h>
|
||||
#include <libgen.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -202,6 +203,8 @@ main(int argc, char *argv[])
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, rvk_fds) == -1)
|
||||
err(EXIT_FAILURE, "socketpair");
|
||||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
/* Start with the network-touching process. */
|
||||
|
||||
if ((pids[COMP_NET] = fork()) == -1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: util.c,v 1.13 2022/12/28 21:30:15 jmc Exp $ */
|
||||
/* $Id: util.c,v 1.14 2024/06/19 13:13:25 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
*
|
||||
@ -21,7 +21,6 @@
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -31,8 +30,6 @@
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
static volatile sig_atomic_t sig;
|
||||
|
||||
static const char *const comps[COMP__MAX] = {
|
||||
"netproc", /* COMP_NET */
|
||||
"keyproc", /* COMP_KEY */
|
||||
@ -71,14 +68,6 @@ static const char *const comms[COMM__MAX] = {
|
||||
"revoke-response", /* COMM_REVOKE_RESP */
|
||||
};
|
||||
|
||||
static void
|
||||
sigpipe(int code)
|
||||
{
|
||||
|
||||
(void)code;
|
||||
sig = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This will read a long-sized operation.
|
||||
* Operations are usually enums, so this should be alright.
|
||||
@ -169,21 +158,15 @@ readbuf(int fd, enum comm comm, size_t *sz)
|
||||
int
|
||||
writeop(int fd, enum comm comm, long op)
|
||||
{
|
||||
void (*sigfp)(int);
|
||||
ssize_t ssz;
|
||||
int er;
|
||||
|
||||
sigfp = signal(SIGPIPE, sigpipe);
|
||||
|
||||
if ((ssz = write(fd, &op, sizeof(long))) == -1) {
|
||||
if ((er = errno) != EPIPE)
|
||||
warn("write: %s", comms[comm]);
|
||||
signal(SIGPIPE, sigfp);
|
||||
return er == EPIPE ? 0 : -1;
|
||||
}
|
||||
|
||||
signal(SIGPIPE, sigfp);
|
||||
|
||||
if ((size_t)ssz != sizeof(long)) {
|
||||
warnx("short write: %s", comms[comm]);
|
||||
return -1;
|
||||
@ -201,21 +184,16 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz)
|
||||
{
|
||||
ssize_t ssz;
|
||||
int er, rc = -1;
|
||||
void (*sigfp)(int);
|
||||
|
||||
/*
|
||||
* First, try to write the length.
|
||||
* If the other end of the pipe has closed, we allow the short
|
||||
* write to propagate as a return value of zero.
|
||||
* To detect this, catch SIGPIPE.
|
||||
*/
|
||||
|
||||
sigfp = signal(SIGPIPE, sigpipe);
|
||||
|
||||
if ((ssz = write(fd, &sz, sizeof(size_t))) == -1) {
|
||||
if ((er = errno) != EPIPE)
|
||||
warn("write: %s length", comms[comm]);
|
||||
signal(SIGPIPE, sigfp);
|
||||
return er == EPIPE ? 0 : -1;
|
||||
}
|
||||
|
||||
@ -233,7 +211,6 @@ writebuf(int fd, enum comm comm, const void *v, size_t sz)
|
||||
else
|
||||
rc = 1;
|
||||
|
||||
signal(SIGPIPE, sigfp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user