summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Modules/_posixsubprocess.c
diff options
context:
space:
mode:
authorshadchin <[email protected]>2024-02-07 09:25:06 +0300
committerAlexander Smirnov <[email protected]>2024-02-09 19:18:32 +0300
commitf0785dc88eee3da0f1514f5b4cafa931571e669d (patch)
tree44165310ad6023cd29776f9b1b4477364cd2b5bb /contrib/tools/python3/src/Modules/_posixsubprocess.c
parent2c0985fb513cb5b352324abf223bf749c6c2bd24 (diff)
Update Python 3 to 3.11.8
Diffstat (limited to 'contrib/tools/python3/src/Modules/_posixsubprocess.c')
-rw-r--r--contrib/tools/python3/src/Modules/_posixsubprocess.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/contrib/tools/python3/src/Modules/_posixsubprocess.c b/contrib/tools/python3/src/Modules/_posixsubprocess.c
index 072519c91a0..d91bf214b46 100644
--- a/contrib/tools/python3/src/Modules/_posixsubprocess.c
+++ b/contrib/tools/python3/src/Modules/_posixsubprocess.c
@@ -566,9 +566,10 @@ child_exec(char *const exec_array[],
PyObject *preexec_fn,
PyObject *preexec_fn_args_tuple)
{
- int i, saved_errno, reached_preexec = 0;
+ int i, saved_errno;
PyObject *result;
- const char* err_msg = "";
+ /* Indicate to the parent that the error happened before exec(). */
+ const char *err_msg = "noexec";
/* Buffer large enough to hold a hex integer. We can't malloc. */
char hex_errno[sizeof(saved_errno)*2+1];
@@ -628,8 +629,12 @@ child_exec(char *const exec_array[],
/* We no longer manually close p2cread, c2pwrite, and errwrite here as
* _close_open_fds takes care when it is not already non-inheritable. */
- if (cwd)
- POSIX_CALL(chdir(cwd));
+ if (cwd) {
+ if (chdir(cwd) == -1) {
+ err_msg = "noexec:chdir";
+ goto error;
+ }
+ }
if (child_umask >= 0)
umask(child_umask); /* umask() always succeeds. */
@@ -672,7 +677,7 @@ child_exec(char *const exec_array[],
#endif /* HAVE_SETREUID */
- reached_preexec = 1;
+ err_msg = "";
if (preexec_fn != Py_None && preexec_fn_args_tuple) {
/* This is where the user has asked us to deadlock their program. */
result = PyObject_Call(preexec_fn, preexec_fn_args_tuple, NULL);
@@ -730,16 +735,12 @@ error:
}
_Py_write_noraise(errpipe_write, cur, hex_errno + sizeof(hex_errno) - cur);
_Py_write_noraise(errpipe_write, ":", 1);
- if (!reached_preexec) {
- /* Indicate to the parent that the error happened before exec(). */
- _Py_write_noraise(errpipe_write, "noexec", 6);
- }
/* We can't call strerror(saved_errno). It is not async signal safe.
* The parent process will look the error message up. */
} else {
_Py_write_noraise(errpipe_write, "SubprocessError:0:", 18);
- _Py_write_noraise(errpipe_write, err_msg, strlen(err_msg));
}
+ _Py_write_noraise(errpipe_write, err_msg, strlen(err_msg));
}