-/* $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>
*
#include <err.h>
#include <libgen.h>
#include <locale.h>
+#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
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)
-/* $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>
*
#include <err.h>
#include <errno.h>
#include <limits.h>
-#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "extern.h"
-static volatile sig_atomic_t sig;
-
static const char *const comps[COMP__MAX] = {
"netproc", /* COMP_NET */
"keyproc", /* COMP_KEY */
"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.
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;
{
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;
}
else
rc = 1;
- signal(SIGPIPE, sigfp);
return rc;
}