From 01362062a8323ab98e9c3626881e56f157c81939 Mon Sep 17 00:00:00 2001 From: claudio Date: Thu, 4 Nov 2021 18:00:07 +0000 Subject: [PATCH] On errors related to the pipes to the childs don't error out right away. Instead exit the main event loop and use waitpid to know why a child went away. This should make it hopefully more clear when shit hits the fan. OK tb@ deraadt@ --- usr.sbin/rpki-client/main.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c index c11a28b3122..4ea97df451a 100644 --- a/usr.sbin/rpki-client/main.c +++ b/usr.sbin/rpki-client/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.162 2021/11/04 14:24:41 claudio Exp $ */ +/* $OpenBSD: main.c,v 1.163 2021/11/04 18:00:07 claudio Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -1020,19 +1020,23 @@ main(int argc, char *argv[]) } for (i = 0; i < NPFD; i++) { - if (pfd[i].revents & (POLLERR|POLLNVAL)) - errx(1, "poll[%zu]: bad fd", i); - if (pfd[i].revents & POLLHUP) { - warnx("poll[%zu]: hangup", i); + if (pfd[i].revents & (POLLERR|POLLNVAL)) { + warnx("poll[%zu]: bad fd", i); hangup = 1; } + if (pfd[i].revents & POLLHUP) + hangup = 1; if (pfd[i].revents & POLLOUT) { switch (msgbuf_write(queues[i])) { case 0: - errx(1, "write[%zu]: " + warnx("write[%zu]: " "connection closed", i); + hangup = 1; + break; case -1: - err(1, "write[%zu]", i); + warn("write[%zu]", i); + hangup = 1; + break; } } } @@ -1147,7 +1151,7 @@ main(int argc, char *argv[]) /* processing did not finish because of error */ if (entity_queue != 0) - return 1; + errx(1, "not all files processed, giving up"); logx("all files parsed: generating output"); -- 2.20.1