summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorneumann <neumann>2023-07-25 09:01:51 (GMT)
committerneumann <neumann>2023-07-25 09:01:51 (GMT)
commitd880550d56911af6fdba25b4863bc8e49d4df29f (patch)
treeb4e073dfd296c3ce4b8308fd2fc44de7727ede3f /unix
parentc1e69b2d6bffd5ec2ca5e44da5fc0754a51b0249 (diff)
downloadtcl-d880550d56911af6fdba25b4863bc8e49d4df29f.zip
tcl-d880550d56911af6fdba25b4863bc8e49d4df29f.tar.gz
tcl-d880550d56911af6fdba25b4863bc8e49d4df29f.tar.bz2
Prefer vfork() over posix_spawnp()
In essence, older versions of the posix_spawn(p) implementation under glibc have the problem not returning the correct error number in case the spawn call fails. This is e.g. a problem with CentOS 7, which uses GNU libc 2.17, which was released 2012-12-25. This has the consequence that on such systems, Tcl is not error message compliant to versions without posix_spawn. The versions of vfork() do not face this problem and show similar performance characteristics like with posix_spawnp() (spawn time in essence independent of memory footprint size). This change was tested with macOS 13.4, Ubuntu 20.04, CentOS 7.9 and OpenBSD 7.2.
Diffstat (limited to 'unix')
-rw-r--r--unix/tcl.m41
-rw-r--r--unix/tclUnixPort.h14
2 files changed, 15 insertions, 0 deletions
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index dfa812b..9d2c38c 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -2069,6 +2069,7 @@ dnl # preprocessing tests use only CPPFLAGS.
# Check for posix_spawnp() and friends unconditionally
AC_CHECK_FUNCS(posix_spawnp posix_spawn_file_actions_adddup2 posix_spawnattr_setflags)
+ AC_CHECK_FUNCS([vfork])
# FIXME: This subst was left in only because the TCL_DL_LIBS
# entry in tclConfig.sh uses it. It is not clear why someone
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index c2115df..ea4beac 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -636,6 +636,20 @@ extern char ** environ;
defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050
# warning "Weak import of 64-bit CoreFoundation is not supported, will not run on Mac OS X < 10.5."
# endif
+# if defined(HAVE_POSIX_SPAWNP)
+/*
+ * Under macOS, test exec-17.1 fails (I/O setup after closing stdout) with
+ * posix_spawnp(), but the classic implementation (based on fork()+execvp())
+ * works without the severe performance implications with large memory
+ * footprints. So, deactivate HAVE_POSIX_SPAWNP
+ */
+# undef HAVE_POSIX_SPAWNP
+# endif
+#else
+# if defined(HAVE_POSIX_SPAWNP) && defined(HAVE_VFORK)
+# define USE_VFORK
+# undef HAVE_POSIX_SPAWNP
+# endif
#endif /* __APPLE__ */
/*