Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/python/cpython/src/patches/09-set-inheritable.patch
1067 views
1
--- native/Python/fileutils.c 2022-09-11 12:23:30.000000000 -0700
2
+++ wasm/Python/fileutils.c 2022-09-18 11:58:42.000000000 -0700
3
@@ -1323,11 +1323,25 @@
4
return get_inheritable(fd, 1);
5
}
6
7
+extern int python_wasm_set_inheritable(int fd, int inheritable);
8
9
/* This function MUST be kept async-signal-safe on POSIX when raise=0. */
10
static int
11
set_inheritable(int fd, int inheritable, int raise, int *atomic_flag_works)
12
{
13
+ // For python-wasm we *have* to write this ourselves, since fcntl is
14
+ // built into upstream WASI and it makes this sort of stuff a no-op, or
15
+ // at least no functions in wasi get called. Note that this has limited
16
+ // impact, e.g., it can only work in a WASI context for certain types of
17
+ // fd's, e.g., pipes.
18
+ int result = python_wasm_set_inheritable(fd, inheritable);
19
+ if (result < 0) {
20
+ if (raise)
21
+ PyErr_SetFromErrno(PyExc_OSError);
22
+ return -1;
23
+ }
24
+ return 0;
25
+
26
#ifdef MS_WINDOWS
27
HANDLE handle;
28
DWORD flags;
29
30