aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIhor Antonov <ihor@antonovs.family>2023-03-03 05:17:02 +0000
committerKyle Evans <kevans@FreeBSD.org>2023-03-17 21:01:02 +0000
commitbc9d2ee0a7acab55e2625d10f937305b8ba4231a (patch)
treedc85aabdea288af4f1e43277f0fdce7d7c155ab8
parentbb2e206cae8ba120f9d1ef78149e61ff3f003fb0 (diff)
downloadsrc-bc9d2ee0a7acab55e2625d10f937305b8ba4231a.tar.gz
src-bc9d2ee0a7acab55e2625d10f937305b8ba4231a.zip
daemon: simplify if/else chain
Reviewed by: kevans Pull Request: https://github.com/freebsd/freebsd-src/pull/672 (cherry picked from commit cd1e6e70d001bea9e9e0220bdfdbd8b5dd9922de)
-rw-r--r--usr.sbin/daemon/daemon.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c
index 5c636bcd0a03..2274a3e253a0 100644
--- a/usr.sbin/daemon/daemon.c
+++ b/usr.sbin/daemon/daemon.c
@@ -452,22 +452,16 @@ restart:
*/
if (child_gone && child_eof) {
break;
- } else if (terminate) {
+ }
+
+ if (terminate) {
goto exit;
- } else if (!child_eof) {
- if (sigprocmask(SIG_BLOCK, &mask_read, NULL)) {
- warn("sigprocmask");
- goto exit;
- }
- child_eof = !listen_child(pfd[0], &logparams);
- if (sigprocmask(SIG_UNBLOCK, &mask_read, NULL)) {
- warn("sigprocmask");
- goto exit;
- }
- } else {
+ }
+
+ if (child_eof) {
if (sigprocmask(SIG_BLOCK, &mask_susp, NULL)) {
warn("sigprocmask");
- goto exit;
+ goto exit;
}
while (!terminate && !child_gone)
sigsuspend(&mask_orig);
@@ -475,7 +469,21 @@ restart:
warn("sigprocmask");
goto exit;
}
+ continue;
+ }
+
+ if (sigprocmask(SIG_BLOCK, &mask_read, NULL)) {
+ warn("sigprocmask");
+ goto exit;
}
+
+ child_eof = !listen_child(pfd[0], &logparams);
+
+ if (sigprocmask(SIG_UNBLOCK, &mask_read, NULL)) {
+ warn("sigprocmask");
+ goto exit;
+ }
+
}
if (restart && !terminate) {
daemon_sleep(restart, 0);