From 32cda0c8683c2817afb5eee58662fd445f688408 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 26 Mar 2018 13:25:51 +0200 Subject: [PATCH] fd-util: introduce fd_reopen() helper for reopening an fd We have the same code for this in place at various locations, let's unify that. Also, let's repurpose test-fs-util.c as a test for this new helper cal.. --- src/basic/fd-util.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index db259e6d1..0f5a950f1 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -102,10 +102,6 @@ int acquire_data_fd(const void *data, size_t size, unsigned flags); #define ERRNO_IS_DISCONNECT(r) \ IN_SET(r, ENOTCONN, ECONNRESET, ECONNREFUSED, ECONNABORTED, EPIPE, ENETUNREACH) -/* Resource exhaustion, could be our fault or general system trouble */ -#define ERRNO_IS_RESOURCE(r) \ - IN_SET(r, ENOMEM, EMFILE, ENFILE) - int fd_move_above_stdio(int fd); int rearrange_stdio(int original_input_fd, int original_output_fd, int original_error_fd); @@ -121,3 +117,5 @@ static inline int make_null_stdio(void) { (fd) = -1; \ _fd_; \ }) + +int fd_reopen(int fd, int flags); -- 2.30.2