diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2022-01-18 11:27:54 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2022-01-18 12:27:29 -0500 |
commit | 03563b1407e436b2863509ebf09d412e79cbd1dd (patch) | |
tree | d2e5b735c8be3078b7b76c31c9168330a7f2557b /main.c | |
parent | abbb00766a8d10f63bbafb60bb13eb4672d7f44a (diff) | |
download | bfs-03563b1407e436b2863509ebf09d412e79cbd1dd.tar.xz |
util: New close() wrappers to check for EBADF and preserve errno
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -1,6 +1,6 @@ /**************************************************************************** * bfs * - * Copyright (C) 2015-2021 Tavian Barnes <tavianator@tavianator.com> * + * Copyright (C) 2015-2022 Tavian Barnes <tavianator@tavianator.com> * * * * Permission to use, copy, modify, and/or distribute this software for any * * purpose with or without fee is hereby granted. * @@ -54,6 +54,7 @@ #include "ctx.h" #include "eval.h" #include "parse.h" +#include "util.h" #include <errno.h> #include <fcntl.h> #include <locale.h> @@ -79,9 +80,7 @@ static int redirect(int fd, const char *path, int flags) { } int ret = dup2(newfd, fd); - int err = errno; - close(newfd); - errno = err; + close_quietly(newfd); return ret; } |