From e7685a77b41bbd1b8289aeaf75fccaf4bb68a361 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 26 Feb 2018 15:41:38 +0100 Subject: util: add new safe_close_above_stdio() wrapper At various places we only want to close fds if they are not stdin/stdout/stderr, i.e. fds 0, 1, 2. Let's add a unified helper call for that, and port everything over. --- src/journal/cat.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/journal/cat.c') diff --git a/src/journal/cat.c b/src/journal/cat.c index b2f9ed5010..c87a149a4c 100644 --- a/src/journal/cat.c +++ b/src/journal/cat.c @@ -141,9 +141,7 @@ int main(int argc, char *argv[]) { goto finish; } - if (fd >= 3) - safe_close(fd); - fd = -1; + fd = safe_close_above_stdio(fd); if (argc <= optind) (void) execl("/bin/cat", "/bin/cat", NULL); -- cgit v1.2.1