diff options
author | shadchin <shadchin@yandex-team.com> | 2025-02-16 15:28:01 +0300 |
---|---|---|
committer | shadchin <shadchin@yandex-team.com> | 2025-02-16 16:03:50 +0300 |
commit | a27b6a96fdc5ca444428ddef4823d0486dcdccb9 (patch) | |
tree | adde5c24d9ea37e1634e7972e27e682a820ab941 /contrib/tools/python3/Modules/posixmodule.c | |
parent | 7a3958c3c6de324baab9dba4bd4eb808c1b839a6 (diff) | |
download | ydb-a27b6a96fdc5ca444428ddef4823d0486dcdccb9.tar.gz |
Update Python 3 to 3.12.9
commit_hash:c8651982d81e18f18e037fb247cc6ae53c4fa7f1
Diffstat (limited to 'contrib/tools/python3/Modules/posixmodule.c')
-rw-r--r-- | contrib/tools/python3/Modules/posixmodule.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/contrib/tools/python3/Modules/posixmodule.c b/contrib/tools/python3/Modules/posixmodule.c index ce2c80e6da..3707516550 100644 --- a/contrib/tools/python3/Modules/posixmodule.c +++ b/contrib/tools/python3/Modules/posixmodule.c @@ -49,10 +49,6 @@ # include "winreparse.h" #endif -#if !defined(EX_OK) && defined(EXIT_SUCCESS) -# define EX_OK EXIT_SUCCESS -#endif - /* On android API level 21, 'AT_EACCESS' is not declared although * HAVE_FACCESSAT is defined. */ #ifdef __ANDROID__ @@ -61,6 +57,9 @@ #include <stdio.h> // ctermid() #include <stdlib.h> // system() +#ifdef HAVE_SYS_PIDFD_H +# error #include <sys/pidfd.h> // PIDFD_NONBLOCK +#endif /* * A number of APIs are available on macOS from a certain macOS version. @@ -267,6 +266,10 @@ corresponding Unix manual entries for more information on calls."); # include <sysexits.h> #endif +#if !defined(EX_OK) && defined(EXIT_SUCCESS) +# define EX_OK EXIT_SUCCESS +#endif + #ifdef HAVE_SYS_LOADAVG_H # include <sys/loadavg.h> #endif @@ -3235,7 +3238,7 @@ os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd, #endif -#ifdef HAVE_TTYNAME +#ifdef HAVE_TTYNAME_R /*[clinic input] os.ttyname @@ -8982,42 +8985,33 @@ os_kill_impl(PyObject *module, pid_t pid, Py_ssize_t signal) Py_RETURN_NONE; #else /* !MS_WINDOWS */ - PyObject *result; DWORD sig = (DWORD)signal; - DWORD err; - HANDLE handle; #ifdef HAVE_WINDOWS_CONSOLE_IO /* Console processes which share a common console can be sent CTRL+C or CTRL+BREAK events, provided they handle said events. */ if (sig == CTRL_C_EVENT || sig == CTRL_BREAK_EVENT) { if (GenerateConsoleCtrlEvent(sig, (DWORD)pid) == 0) { - err = GetLastError(); - PyErr_SetFromWindowsErr(err); - } - else { - Py_RETURN_NONE; + return PyErr_SetFromWindowsErr(0); } + Py_RETURN_NONE; } #endif /* HAVE_WINDOWS_CONSOLE_IO */ /* If the signal is outside of what GenerateConsoleCtrlEvent can use, attempt to open and terminate the process. */ - handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); + HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); if (handle == NULL) { - err = GetLastError(); - return PyErr_SetFromWindowsErr(err); + return PyErr_SetFromWindowsErr(0); } - if (TerminateProcess(handle, sig) == 0) { - err = GetLastError(); - result = PyErr_SetFromWindowsErr(err); - } else { - result = Py_NewRef(Py_None); + BOOL res = TerminateProcess(handle, sig); + CloseHandle(handle); + if (res == 0) { + return PyErr_SetFromWindowsErr(0); } - CloseHandle(handle); - return result; + Py_RETURN_NONE; #endif /* !MS_WINDOWS */ } #endif /* HAVE_KILL */ |