@@ -1500,10 +1500,31 @@ index 44974d433b..ae4e18802b 100755
1500
1500
#
1501
1501
# Platform support for Windows
1502
1502
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
1503
- index 9132f13e81..c6901a31d5 100644
1503
+ index 9132f13e81..36e00f7bfd 100644
1504
1504
--- a/Modules/_posixsubprocess.c
1505
1505
+++ b/Modules/_posixsubprocess.c
1506
- @@ -660,11 +660,15 @@
1506
+ @@ -31,10 +31,20 @@
1507
+
1508
+ #include "posixmodule.h"
1509
+
1510
+ + #if defined(__APPLE__)
1511
+ + #include "TargetConditionals.h"
1512
+ + #endif
1513
+ +
1514
+ #ifdef _Py_MEMORY_SANITIZER
1515
+ # include <sanitizer/msan_interface.h>
1516
+ #endif
1517
+
1518
+ + // iOS/tvOS/watchOS *define* a number of POSIX functions, but you can't use them
1519
+ + // because they aren't conventional multiprocess environments.
1520
+ + #if TARGET_OS_IPHONE
1521
+ + # undef HAVE_FORK
1522
+ + #endif
1523
+ +
1524
+ #if defined(__ANDROID__) && __ANDROID_API__ < 21 && !defined(SYS_getdents64)
1525
+ # include <sys/linux-syscalls.h>
1526
+ # define SYS_getdents64 __NR_getdents64
1527
+ @@ -660,11 +670,15 @@
1507
1528
saved_errno = 0;
1508
1529
for (i = 0; exec_array[i] != NULL; ++i) {
1509
1530
const char *executable = exec_array[i];
@@ -1519,18 +1540,93 @@ index 9132f13e81..c6901a31d5 100644
1519
1540
if (errno != ENOENT && errno != ENOTDIR && saved_errno == 0) {
1520
1541
saved_errno = errno;
1521
1542
}
1522
- @@ -751,7 +755,11 @@
1543
+ @@ -730,7 +744,9 @@
1544
+ PyObject *preexec_fn,
1545
+ PyObject *preexec_fn_args_tuple)
1546
+ {
1547
+ -
1548
+ + /* iOS/tvOS/watchOS define the existence of fork, but it cannot be invoked;
1549
+ + * so fail fast if any attempt is made to invoke fork_exec */
1550
+ + #ifdef HAVE_FORK
1551
+ pid_t pid;
1552
+
1553
+ #ifdef VFORK_USABLE
1554
+ @@ -749,7 +765,7 @@
1555
+ pid = fork();
1556
+ }
1523
1557
} else
1524
- #endif
1558
+ - #endif
1559
+ + #endif /* VFORK_USABLE */
1525
1560
{
1526
- + #if defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
1527
- + pid = -1;
1528
- + #else
1529
1561
pid = fork();
1530
- + #endif
1531
1562
}
1532
-
1563
+ @@ -757,7 +773,6 @@
1533
1564
if (pid != 0) {
1565
+ return pid;
1566
+ }
1567
+ -
1568
+ /* Child process.
1569
+ * See the comment above child_exec() for restrictions imposed on
1570
+ * the code below.
1571
+ @@ -780,6 +795,9 @@
1572
+ py_fds_to_keep, preexec_fn, preexec_fn_args_tuple);
1573
+ _exit(255);
1574
+ return 0; /* Dead code to avoid a potential compiler warning. */
1575
+ + #else /* HAVE_FORK */
1576
+ + return -1;
1577
+ + #endif /* HAVE_FORK */
1578
+ }
1579
+
1580
+
1581
+ @@ -810,7 +828,9 @@
1582
+ int need_after_fork = 0;
1583
+ int saved_errno = 0;
1584
+ int allow_vfork;
1585
+ -
1586
+ + /* iOS/tvOS/watchOS define the existence of fork, but it cannot be invoked;
1587
+ + * so fail fast if any attempt is made to invoke fork_exec */
1588
+ + #ifdef HAVE_FORK
1589
+ if (!PyArg_ParseTuple(
1590
+ args, "OOpO!OOiiiiiiiiii" _Py_PARSE_PID "OOOiOp:fork_exec",
1591
+ &process_args, &executable_list,
1592
+ @@ -982,7 +1002,6 @@
1593
+ goto cleanup;
1594
+ #endif /* HAVE_SETREUID */
1595
+ }
1596
+ -
1597
+ /* This must be the last thing done before fork() because we do not
1598
+ * want to call PyOS_BeforeFork() if there is any chance of another
1599
+ * error leading to the cleanup: code without calling fork(). */
1600
+ @@ -1017,7 +1036,7 @@
1601
+ }
1602
+ old_sigmask = &old_sigs;
1603
+ }
1604
+ - #endif
1605
+ + #endif /* VFORK_USABLE */
1606
+
1607
+ pid = do_fork_exec(exec_array, argv, envp, cwd,
1608
+ p2cread, p2cwrite, c2pread, c2pwrite,
1609
+ @@ -1049,7 +1068,7 @@
1610
+ * the thread signal mask. */
1611
+ (void) pthread_sigmask(SIG_SETMASK, old_sigmask, NULL);
1612
+ }
1613
+ - #endif
1614
+ + #endif /* VFORK_USABLE */
1615
+
1616
+ if (need_after_fork)
1617
+ PyOS_AfterFork_Parent();
1618
+ @@ -1078,8 +1097,10 @@
1619
+ PyGC_Enable();
1620
+ }
1621
+ Py_XDECREF(gc_module);
1622
+ -
1623
+ return pid == -1 ? NULL : PyLong_FromPid(pid);
1624
+ + #else /* HAVE_FORK */
1625
+ + return NULL;
1626
+ + #endif
1627
+ }
1628
+
1629
+
1534
1630
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
1535
1631
index 08c40834c4..5c110d7211 100644
1536
1632
--- a/Modules/faulthandler.c
@@ -1556,7 +1652,7 @@ index 08c40834c4..5c110d7211 100644
1556
1652
and sigaction() SA_ONSTACK */
1557
1653
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
1558
1654
diff --git a/Modules/makesetup b/Modules/makesetup
1559
- index 9b20e3c9f6..196ff69984 100755
1655
+ index 9b20e3c9f6..23be532f6a 100755
1560
1656
--- a/Modules/makesetup
1561
1657
+++ b/Modules/makesetup
1562
1658
@@ -166,7 +166,7 @@
@@ -1576,7 +1672,25 @@ index 9b20e3c9f6..196ff69984 100755
1576
1672
\$\(*_CFLAGS\)) cpps="$cpps $arg";;
1577
1673
\$\(*_INCLUDES\)) cpps="$cpps $arg";;
1578
1674
\$\(*_LIBS\)) libs="$libs $arg";;
1579
- @@ -245,6 +246,7 @@
1675
+ @@ -220,7 +221,16 @@
1676
+ done
1677
+ case $doconfig in
1678
+ yes)
1679
+ - LIBS="$LIBS $libs"
1680
+ + # sed has a character limit for multiline substitutions on some
1681
+ + # installs. If you have a lot of customized module configurations,
1682
+ + # the LOCALMODLIBS definition can end up exceeding that line length.
1683
+ + # To ensure this doesn't happen, only include $libs if it adds
1684
+ + # something, and put each library definition on it's own line. This
1685
+ + # requires escaping for when this script runs, and escaping for when
1686
+ + # the output is run through sed.
1687
+ + if test "$libs"; then
1688
+ + LIBS="$LIBS \\\\\\\\\\$NL\t$libs"
1689
+ + fi
1690
+ MODS="$MODS $mods"
1691
+ BUILT="$BUILT $mods"
1692
+ ;;
1693
+ @@ -245,6 +255,7 @@
1580
1694
*.C) obj=`basename $src .C`.o; cc='$(CXX)';;
1581
1695
*.cxx) obj=`basename $src .cxx`.o; cc='$(CXX)';;
1582
1696
*.cpp) obj=`basename $src .cpp`.o; cc='$(CXX)';;
@@ -1600,7 +1714,7 @@ index aa93e756c6..fcf3784c2f 100644
1600
1714
sin(pi*x), giving accurate results for all finite x (especially x
1601
1715
integral or close to an integer). This is here for use in the
1602
1716
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
1603
- index 4015889441..3cacff0f3f 100644
1717
+ index 4015889441..b9d6633213 100644
1604
1718
--- a/Modules/posixmodule.c
1605
1719
+++ b/Modules/posixmodule.c
1606
1720
@@ -69,6 +69,8 @@
@@ -1617,7 +1731,7 @@ index 4015889441..3cacff0f3f 100644
1617
1731
#endif /* ! __WATCOMC__ || __QNX__ */
1618
1732
1619
1733
+ // iOS/tvOS/watchOS *define* a number of POSIX functions, but you can't use them
1620
- + // because iOS isn't a conventional multiprocess environment.
1734
+ + // because they aren't conventional multiprocess environment.
1621
1735
+ #if TARGET_OS_IPHONE
1622
1736
+ # undef HAVE_EXECV
1623
1737
+ # undef HAVE_FORK
0 commit comments