summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2010-02-07 19:56:39 (GMT)
committerRonald Oussoren <ronaldoussoren@mac.com>2010-02-07 19:56:39 (GMT)
commit755740f3ea9c5005d16a80c07e7fc26e45f11aa1 (patch)
tree5c764709032b00db8244cde4a358025f61ef5751 /Mac
parenta5336b60007476389cb3102b9c020bc78c3fca76 (diff)
downloadcpython-755740f3ea9c5005d16a80c07e7fc26e45f11aa1.zip
cpython-755740f3ea9c5005d16a80c07e7fc26e45f11aa1.tar.gz
cpython-755740f3ea9c5005d16a80c07e7fc26e45f11aa1.tar.bz2
Forward port a number of OSX bugfixes from the trunk to 3.2
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Makefile.in1
-rw-r--r--Mac/Tools/pythonw.c33
2 files changed, 29 insertions, 5 deletions
diff --git a/Mac/Makefile.in b/Mac/Makefile.in
index b1d4456..31d3b9f 100644
--- a/Mac/Makefile.in
+++ b/Mac/Makefile.in
@@ -16,6 +16,7 @@ FRAMEWORKUNIXTOOLSPREFIX=@FRAMEWORKUNIXTOOLSPREFIX@
PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
+CC=@CC@
# These are normally glimpsed from the previous set
diff --git a/Mac/Tools/pythonw.c b/Mac/Tools/pythonw.c
index d7a86f2..bd50f5c 100644
--- a/Mac/Tools/pythonw.c
+++ b/Mac/Tools/pythonw.c
@@ -6,9 +6,21 @@
*
* This program uses posix_spawn rather than plain execv because we need
* slightly more control over how the "real" interpreter is executed.
+ *
+ * On OSX 10.4 (and earlier) this falls back to using exec because the
+ * posix_spawnv functions aren't available there.
*/
+
+#pragma weak_import posix_spawnattr_init
+#pragma weak_import posix_spawnattr_setbinpref_np
+#pragma weak_import posix_spawnattr_setflags
+#pragma weak_import posix_spawn
+
+#include <Python.h>
#include <unistd.h>
+#ifdef HAVE_SPAWN_H
#include <spawn.h>
+#endif
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -74,6 +86,7 @@ static char* get_python_path(void)
return g_path;
}
+#ifdef HAVE_SPAWN_H
static void
setup_spawnattr(posix_spawnattr_t* spawnattr)
{
@@ -132,16 +145,26 @@ setup_spawnattr(posix_spawnattr_t* spawnattr)
/* NOTREACHTED */
}
}
+#endif
int
main(int argc, char **argv) {
- posix_spawnattr_t spawnattr = NULL;
char* exec_path = get_python_path();
+#ifdef HAVE_SPAWN_H
+ /* We're weak-linking to posix-spawnv to ensure that
+ * an executable build on 10.5 can work on 10.4.
+ */
+ if (posix_spawn != NULL) {
+ posix_spawnattr_t spawnattr = NULL;
- setup_spawnattr(&spawnattr);
- posix_spawn(NULL, exec_path, NULL,
- &spawnattr, argv, environ);
- err(1, "posix_spawn: %s", argv[0]);
+ setup_spawnattr(&spawnattr);
+ posix_spawn(NULL, exec_path, NULL,
+ &spawnattr, argv, environ);
+ err(1, "posix_spawn: %s", argv[0]);
+ }
+#endif
+ execve(exec_path, argv, environ);
+ err(1, "execve: %s", argv[0]);
/* NOTREACHED */
}