cronie/backport-anacron-Use-xclose-instead-of-fclose.patch
2023-12-04 15:51:09 +08:00

48 lines
1.4 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 880489e42a652b84c7de348f0167dfd26abca326 Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
Date: Fri, 13 Oct 2023 10:40:05 +0200
Subject: [PATCH] anacron: Use xclose() instead of fclose()
When replacing standard descriptors we use
xclose() elsewhere and it is less error-prone.
Fixes #156
---
anacron/main.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/anacron/main.c b/anacron/main.c
index 65f8fed..1ad904a 100644
--- a/anacron/main.c
+++ b/anacron/main.c
@@ -209,13 +209,13 @@ go_background(void)
/* stdin is already closed */
- if (fclose(stdout)) die_e("Can't close stdout");
+ xclose(STDOUT_FILENO);
/* coverity[leaked_handle] fd 1 closed automatically */
- xopen(1, "/dev/null", O_WRONLY);
+ xopen(STDOUT_FILENO, "/dev/null", O_WRONLY);
- if (fclose(stderr)) die_e("Can't close stderr");
+ xclose(STDERR_FILENO);
/* coverity[leaked_handle] fd 2 closed automatically */
- xopen(2, "/dev/null", O_WRONLY);
+ xopen(STDERR_FILENO, "/dev/null", O_WRONLY);
pid = xfork();
if (pid != 0)
@@ -476,7 +476,7 @@ main(int argc, char *argv[])
if (sigprocmask(0, NULL, &old_sigmask)) die_e("sigset error");
- if (fclose(stdin)) die_e("Can't close stdin");
+ xclose(STDIN_FILENO);
xopen(STDIN_FILENO, "/dev/null", O_RDONLY);
if (!no_daemon && !testing_only)
--
2.33.0