aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-10-31 13:35:54 -0600
committerGitHub <noreply@github.com>2022-10-31 12:35:54 -0700
commit4702552885811d0af8f0e4545f494336801ad4dd (patch)
treea8d24ed97f3e4561bf79ce6d27bd46cba2ecb303 /Python/pylifecycle.c
parent3b86538661038ee23d0be80bb7593e2e7856f059 (diff)
downloadcpython-4702552885811d0af8f0e4545f494336801ad4dd.tar.gz
cpython-4702552885811d0af8f0e4545f494336801ad4dd.zip
gh-98610: Adjust the Optional Restrictions on Subinterpreters (GH-98618)
Previously, the optional restrictions on subinterpreters were: disallow fork, subprocess, and threads. By default, we were disallowing all three for "isolated" interpreters. We always allowed all three for the main interpreter and those created through the legacy `Py_NewInterpreter()` API. Those settings were a bit conservative, so here we've adjusted the optional restrictions to: fork, exec, threads, and daemon threads. The default for "isolated" interpreters disables fork, exec, and daemon threads. Regular threads are allowed by default. We continue always allowing everything For the main interpreter and the legacy API. In the code, we add `_PyInterpreterConfig.allow_exec` and `_PyInterpreterConfig.allow_daemon_threads`. We also add `Py_RTFLAGS_DAEMON_THREADS` and `Py_RTFLAGS_EXEC`.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index d26ae74a0f1..e64849296c5 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -615,15 +615,21 @@ static void
init_interp_settings(PyInterpreterState *interp, const _PyInterpreterConfig *config)
{
assert(interp->feature_flags == 0);
+
if (config->allow_fork) {
interp->feature_flags |= Py_RTFLAGS_FORK;
}
- if (config->allow_subprocess) {
- interp->feature_flags |= Py_RTFLAGS_SUBPROCESS;
+ if (config->allow_exec) {
+ interp->feature_flags |= Py_RTFLAGS_EXEC;
}
+ // Note that fork+exec is always allowed.
+
if (config->allow_threads) {
interp->feature_flags |= Py_RTFLAGS_THREADS;
}
+ if (config->allow_daemon_threads) {
+ interp->feature_flags |= Py_RTFLAGS_DAEMON_THREADS;
+ }
}