From 055db7703d609d36e4c35a3967c3625237bcef61 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 14 Aug 2003 23:07:29 +0000 Subject: [PATCH] (CLEANUP_CWD): Report an error if we failed to return to the initial working directory. Preserve errno for caller. --- lib/makepath.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/makepath.c b/lib/makepath.c index 0f20bcde9e..f2dfe88914 100644 --- a/lib/makepath.c +++ b/lib/makepath.c @@ -105,10 +105,16 @@ extern int errno; Restore working directory. */ \ if (do_chdir) \ { \ - int _fail = restore_cwd (&cwd, NULL, NULL); \ + if (restore_cwd (&cwd) != 0) \ + { \ + int _saved_errno = errno; \ + error (0, errno, \ + _("failed to return to initial working directory")); \ + free_cwd (&cwd); \ + errno = _saved_errno; \ + return 1; \ + } \ free_cwd (&cwd); \ - if (_fail) \ - return 1; \ } \ } \ while (0) -- 2.30.2