40 lines
1.1 KiB
Diff
40 lines
1.1 KiB
Diff
From 518a0ad4d9c586ca69d3cf924a4328361f6b2a80 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= <crrodriguez@opensuse.org>
|
|
Date: Sun, 15 Jan 2023 01:33:14 +0000
|
|
Subject: [PATCH] lib:pager: fix signal safety issues
|
|
|
|
- Cannot use stdio in signal handlers, so you cannot safely call
|
|
fflush.
|
|
- cannot call exit() but only _exit()
|
|
---
|
|
lib/pager.c | 6 +++---
|
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/lib/pager.c b/lib/pager.c
|
|
index e5bd07a47..8f62310c0 100644
|
|
--- a/lib/pager.c
|
|
+++ b/lib/pager.c
|
|
@@ -114,7 +114,9 @@ static int wait_or_whine(pid_t pid)
|
|
if (waiting < 0) {
|
|
if (errno == EINTR)
|
|
continue;
|
|
- err(EXIT_FAILURE, _("waitpid failed (%s)"), strerror(errno));
|
|
+ /* Can't err() on signal handler */
|
|
+ ignore_result(write(STDERR_FILENO, "waitpid failed", 14));
|
|
+ _exit(EXIT_FAILURE);
|
|
}
|
|
if (waiting != pid)
|
|
return -1;
|
|
@@ -163,8 +165,6 @@ static void wait_for_pager(void)
|
|
if (pager_process.pid == 0)
|
|
return;
|
|
|
|
- fflush(stdout);
|
|
- fflush(stderr);
|
|
/* signal EOF to pager */
|
|
close(STDOUT_FILENO);
|
|
close(STDERR_FILENO);
|
|
--
|
|
2.27.0
|
|
|