From: Lennart Poettering Date: Mon, 26 Mar 2018 11:25:51 +0000 (+0200) Subject: fd-util: introduce fd_reopen() helper for reopening an fd X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=32cda0c8683c2817afb5eee58662fd445f688408;p=elogind.git 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.. --- 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);