diff options
-rw-r--r-- | patches/61_all_process_data.patch | 128 |
1 files changed, 0 insertions, 128 deletions
diff --git a/patches/61_all_process_data.patch b/patches/61_all_process_data.patch deleted file mode 100644 index b0eda4b..0000000 --- a/patches/61_all_process_data.patch +++ /dev/null @@ -1,128 +0,0 @@ -GENTOO_PYTHON_PROCESS_NAME environmental variable is set by python-wrapper and wrapper scripts generated by -python_generate_wrapper_scripts() and specifies process name. -GENTOO_PYTHON_WRAPPER_SCRIPT_PATH environmental variable is set by wrapper scripts generated by -python_generate_wrapper_scripts() and specifies sys.argv[0] in target executables. -GENTOO_PYTHON_TARGET_SCRIPT_PATH environmental variable is set by wrapper scripts generated by -python_generate_wrapper_scripts() and specifies paths to actually executed scripts. -GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION environmental variable is used by wrapper scripts generated by -python_generate_wrapper_scripts() to check if Python supports GENTOO_PYTHON_TARGET_SCRIPT_PATH environmental variable. - ---- Modules/main.c -+++ Modules/main.c -@@ -252,6 +252,7 @@ - int version = 0; - int saw_unbuffered_flag = 0; - PyCompilerFlags cf; -+ char *target_script_name = getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH"); - - cf.cf_flags = 0; - -@@ -486,7 +487,10 @@ - filename = argv[_PyOS_optind]; - - #else -- filename = argv[_PyOS_optind]; -+ if (target_script_name != NULL && *target_script_name != '\0') -+ filename = target_script_name; -+ else -+ filename = argv[_PyOS_optind]; - #endif - } - ---- Modules/posixmodule.c -+++ Modules/posixmodule.c -@@ -604,6 +604,10 @@ - char *p = strchr(*e, '='); - if (p == NULL) - continue; -+ if ((strlen("GENTOO_PYTHON_PROCESS_NAME") == (int)(p-*e) && strncmp("GENTOO_PYTHON_PROCESS_NAME", *e, (int)(p-*e)) == 0) || -+ (strlen("GENTOO_PYTHON_TARGET_SCRIPT_PATH") == (int)(p-*e) && strncmp("GENTOO_PYTHON_TARGET_SCRIPT_PATH", *e, (int)(p-*e)) == 0) || -+ (strlen("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH") == (int)(p-*e) && strncmp("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH", *e, (int)(p-*e)) == 0)) -+ continue; - k = PyString_FromStringAndSize(*e, (int)(p-*e)); - if (k == NULL) { - PyErr_Clear(); ---- Modules/python.c -+++ Modules/python.c -@@ -6,9 +6,22 @@ - #include <floatingpoint.h> - #endif - -+#ifdef __linux__ -+#include <linux/prctl.h> -+#include <sys/prctl.h> -+#ifndef PR_SET_NAME -+#define PR_SET_NAME 15 -+#endif -+#endif -+ - int - main(int argc, char **argv) - { -+ if (getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION")) { -+ printf("GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n"); -+ return 0; -+ } -+ - /* 754 requires that FP exceptions run in "no stop" mode by default, - * and until C vendors implement C99's ways to control FP exceptions, - * Python requires non-stop mode. Alas, some platforms enable FP -@@ -20,5 +33,15 @@ - m = fpgetmask(); - fpsetmask(m & ~FP_X_OFL); - #endif -+ -+#ifdef __linux__ -+ char *process_name = getenv("GENTOO_PYTHON_PROCESS_NAME"); -+#ifdef HAVE_UNSETENV -+ unsetenv("GENTOO_PYTHON_PROCESS_NAME"); -+#endif -+ if (process_name != NULL && *process_name != '\0') -+ prctl(PR_SET_NAME, process_name); -+#endif -+ - return Py_Main(argc, argv); - } ---- Python/sysmodule.c -+++ Python/sysmodule.c -@@ -1578,6 +1578,10 @@ - makeargvobject(int argc, char **argv) - { - PyObject *av; -+ char *wrapper_script_name = getenv("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"); -+#ifdef HAVE_UNSETENV -+ unsetenv("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"); -+#endif - if (argc <= 0 || argv == NULL) { - /* Ensure at least one (empty) argument is seen */ - static char *empty_argv[1] = {""}; -@@ -1602,7 +1606,11 @@ - } else - v = PyString_FromString(argv[i]); - #else -- PyObject *v = PyString_FromString(argv[i]); -+ PyObject *v; -+ if (i == 0 && wrapper_script_name != NULL && *wrapper_script_name != '\0') -+ v = PyString_FromString(wrapper_script_name); -+ else -+ v = PyString_FromString(argv[i]); - #endif - if (v == NULL) { - Py_DECREF(av); -@@ -1630,7 +1638,15 @@ - if (PySys_SetObject("argv", av) != 0) - Py_FatalError("can't assign sys.argv"); - if (updatepath && path != NULL) { -- char *argv0 = argv[0]; -+ char *target_script_name = getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH"); -+#ifdef HAVE_UNSETENV -+ unsetenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH"); -+#endif -+ char *argv0; -+ if (target_script_name != NULL && *target_script_name != '\0') -+ argv0 = target_script_name; -+ else -+ argv0 = argv[0]; - char *p = NULL; - Py_ssize_t n = 0; - PyObject *a; |