aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/save-cwd.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
index fd746584fa8..833783cbab0 100644
--- a/lib/save-cwd.c
+++ b/lib/save-cwd.c
@@ -50,14 +50,14 @@
50 you're still using an obsolete system with these problems, please 50 you're still using an obsolete system with these problems, please
51 send email to the maintainer of this code. */ 51 send email to the maintainer of this code. */
52 52
53#if !defined HAVE_FCHDIR && !defined fchdir
54# define fchdir(fd) (-1)
55#endif
56
53int 57int
54save_cwd (struct saved_cwd *cwd) 58save_cwd (struct saved_cwd *cwd)
55{ 59{
56#ifdef HAVE_FCHDIR
57 cwd->desc = open (".", O_SEARCH | O_CLOEXEC); 60 cwd->desc = open (".", O_SEARCH | O_CLOEXEC);
58#else
59 cwd->desc = -1;
60#endif
61 /* The 'name' member is present only to minimize differences from 61 /* The 'name' member is present only to minimize differences from
62 gnulib. Initialize it to zero, if only to simplify debugging. */ 62 gnulib. Initialize it to zero, if only to simplify debugging. */
63 cwd->name = 0; 63 cwd->name = 0;
@@ -71,16 +71,14 @@ save_cwd (struct saved_cwd *cwd)
71int 71int
72restore_cwd (const struct saved_cwd *cwd) 72restore_cwd (const struct saved_cwd *cwd)
73{ 73{
74#ifdef HAVE_FCHDIR
75 /* Restore the previous directory if possible, to avoid tying down 74 /* Restore the previous directory if possible, to avoid tying down
76 the file system of the new directory (Bug#18232). */ 75 the file system of the new directory (Bug#18232).
76 Don't worry if fchdir fails, as Emacs doesn't care what the
77 working directory is. The fchdir call is inside an 'if' merely to
78 pacify compilers that complain if fchdir's return value is ignored. */
77 if (fchdir (cwd->desc) == 0) 79 if (fchdir (cwd->desc) == 0)
78 return 0; 80 return 0;
79 81
80 /* Don't worry if fchdir fails, as Emacs doesn't care what the
81 working directory is. The fchdir call is inside an 'if' merely to
82 pacify compilers that complain if fchdir's return value is ignored. */
83#endif
84 return 0; 82 return 0;
85} 83}
86 84