summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-05-11 16:42:17 +0000
committerJim Meyering <jim@meyering.net>2004-05-11 16:42:17 +0000
commit8853d12319f146ca59bebf6d65a8623c63621802 (patch)
tree4045afa34b4bf33acb0d5fa9a1a425b2f1936c0c
parent52e15d01277495a096ff526642262d0dc6f888b4 (diff)
downloadcoreutils-8853d12319f146ca59bebf6d65a8623c63621802.tar.xz
(save_cwd) [HAVE_FCHDIR]: Don't fail just
because opening `.' failed. Resort to using xgetcwd.
-rw-r--r--lib/save-cwd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
index 6fb39f0aa..f97e9c4f0 100644
--- a/lib/save-cwd.c
+++ b/lib/save-cwd.c
@@ -1,5 +1,5 @@
/* save-cwd.c -- Save and restore current working directory.
- Copyright (C) 1995, 1997, 1998, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1997, 1998, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -76,7 +76,10 @@ save_cwd (struct saved_cwd *cwd)
#if HAVE_FCHDIR
cwd->desc = open (".", O_RDONLY | O_DIRECTORY);
if (cwd->desc < 0)
- return 1;
+ {
+ cwd->name = xgetcwd ();
+ return cwd->name == NULL;
+ }
# if __sun__ || sun
/* On SunOS 4 and IRIX 5.3, fchdir returns EINVAL when auditing