On 2024-03-31 18:07, NightStrike wrote:
I don't quite understand your animosity here.

I don't see any animosity in Bruno's comments. Clearly the system you're talking about has a severe performance bug, and the question is whether it's worth our limited time to port to buggy systems like that. Since we don't have easy access to these systems, you can't expect us to fix the problems ourselves - you'll need to pitch in if you want a workaround installed.

That being said, does the attached patch (which I have neither tested or installed) fix the problem for you? If not, perhaps you can adjust the patch so that it does work.
From 58eb8e55ebd5812a77153c671b6ed8d387061e5e Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 31 Mar 2024 22:12:38 -0600
Subject: [PATCH] getcwd: port better to buggy file systems

* m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX):
Time out after 5 seconds.
---
 ChangeLog             |  6 ++++++
 m4/getcwd-path-max.m4 | 18 +++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6a2b024832..8c4bc8608d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-03-31  Paul Eggert  <egg...@cs.ucla.edu>
+
+	getcwd: port better to buggy file systems
+	* m4/getcwd-path-max.m4 (gl_FUNC_GETCWD_PATH_MAX):
+	Time out after 5 seconds.
+
 2024-03-31  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Add missing quotation mark to reminder.
diff --git a/m4/getcwd-path-max.m4 b/m4/getcwd-path-max.m4
index d30e75af60..de3a7ca39c 100644
--- a/m4/getcwd-path-max.m4
+++ b/m4/getcwd-path-max.m4
@@ -1,4 +1,4 @@
-# serial 25
+# serial 26
 # Check for several getcwd bugs with long file names.
 # If so, arrange to compile the wrapper function.
 
@@ -15,7 +15,7 @@
 
 AC_DEFUN([gl_FUNC_GETCWD_PATH_MAX],
 [
-  AC_CHECK_DECLS_ONCE([getcwd])
+  AC_CHECK_DECLS_ONCE([getcwd, alarm])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_CHECK_HEADERS_ONCE([unistd.h])
@@ -35,6 +35,9 @@ AC_DEFUN([gl_FUNC_GETCWD_PATH_MAX],
 #else
 # include <direct.h>
 #endif
+#if HAVE_DECL_ALARM
+# include <signal.h>
+#endif
 #include <string.h>
 #include <limits.h>
 #include <sys/stat.h>
@@ -90,12 +93,21 @@ main ()
 #else
   char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1)
            + DIR_NAME_SIZE + BUF_SLOP];
-  char *cwd = getcwd (buf, PATH_MAX);
   size_t initial_cwd_len;
   size_t cwd_len;
   int fail = 0;
   size_t n_chdirs = 0;
 
+#if HAVE_DECL_ALARM
+  /* This test makes some buggy getcwd implementations take a long time,
+     e.g., <https://bugs.gentoo.org/447970>.
+     Give up after 5 seconds; a getcwd slower than that
+     isn't worth using anyway.  */
+  signal (SIGALRM, SIG_DFL);
+  alarm (5);
+#endif
+
+  char *cwd = getcwd (buf, PATH_MAX);
   if (cwd == NULL)
     exit (10);
 
-- 
2.44.0

Reply via email to