From 139e0acf17293673c712f9352c8a33cb03e3e9a0 Mon Sep 17 00:00:00 2001 From: jca Date: Thu, 7 Jul 2022 20:58:57 +0000 Subject: [PATCH] If ppoll(2) exits, log to syslog(3) instead of stderr By default cron runs as a daemon, with stderr redirected to /dev/null. Better not exit silently, as spotted by sthen@, danj@, "wxallowed" on irc/libera and myself. There probably is a bug lurking in ppoll(2) usage or in the syscall implementation. ok millert@ --- usr.sbin/cron/cron.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c index 831a70d5411..b00ffc6fb43 100644 --- a/usr.sbin/cron/cron.c +++ b/usr.sbin/cron/cron.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.c,v 1.80 2022/01/21 22:53:20 millert Exp $ */ +/* $OpenBSD: cron.c,v 1.81 2022/07/07 20:58:57 jca Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -370,8 +370,10 @@ cron_sleep(time_t target, sigset_t *mask) nfds = ppoll(pfd, 1, &timeout, mask); switch (nfds) { case -1: - if (errno != EINTR && errno != EAGAIN) - err(EXIT_FAILURE, "ppoll"); + if (errno != EINTR && errno != EAGAIN) { + syslog(LOG_ERR, "(CRON) DEATH (ppoll failure: %m)"); + exit(EXIT_FAILURE); + } if (errno == EINTR) { if (got_sigchld) { got_sigchld = 0; -- 2.20.1