From eb19d41d5f85f169cee7570f783821cb705ad37a Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 3 Jul 2013 20:33:19 -0400 Subject: do not check error from close(2) On operating systems we support, the behavior is always such that the kernel will do the right thing as far as invalidating the file descriptor, regardless of the eventual return value. Therefore, potentially looping and calling close multiple times is wrong. At best, we call close again on an invalid FD and throw a spurious EBADF error. At worst, we might close an FD which doesn't belong to us when a multi-threaded application opens its own file descriptor between iterations of the loop. Signed-off-by: Dave Reisner Signed-off-by: Allan McRae --- src/pacman/conf.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 5adc96cf..2985aba1 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -257,14 +257,11 @@ static int download_with_xfercommand(const char *url, const char *localpath, cleanup: /* restore the old cwd if we have it */ if(cwdfd >= 0) { - int close_ret; if(fchdir(cwdfd) != 0) { pm_printf(ALPM_LOG_ERROR, _("could not restore working directory (%s)\n"), strerror(errno)); } - do { - close_ret = close(cwdfd); - } while(close_ret == -1 && errno == EINTR); + close(cwdfd); } if(ret == -1) { -- cgit v1.2.3-70-g09d2