(CLEANUP_CWD): Report an error if we failed to return to the initial
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 14 Aug 2003 23:07:29 +0000 (23:07 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 14 Aug 2003 23:07:29 +0000 (23:07 +0000)
working directory.  Preserve errno for caller.

lib/makepath.c

index 0f20bcd..f2dfe88 100644 (file)
@@ -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)