From e672d1a87fbc1e85cb5605b70db7d477a2bb6a64 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Tue, 27 Sep 2011 18:39:56 +0400 Subject: [PATCH] restore: Make reopen_fd_as to print error Signed-off-by: Cyrill Gorcunov --- util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index 47b0f8849..225700b92 100644 --- a/util.c +++ b/util.c @@ -244,9 +244,13 @@ int reopen_fd_as(int new_fd, int old_fd) { if (old_fd != new_fd) { int tmp = dup2(old_fd, new_fd); - if (tmp < 0) + if (tmp < 0) { + pr_perror("Dup on %d -> %d failed\n", old_fd, new_fd); return tmp; - close(old_fd); + } + + /* Just to have error message if failed */ + close_safe(&old_fd); } return new_fd;