changeset 42961:460f8bf58020

osutil: allow disabling setprocname via a define passed to the compiler In some situations, we run a custom python launcher that appears to not set up Py_GetArgcArgv correctly. We then proceed to promptly crash when we attempt to dereference NULL. Being able to completely disable setprocname is beneficial in these situations, since we won't even attempt to use it, even if the case that causes the crash is fixed. Right now, if I compile osutil.so with -DSETPROCNAME_USE_NONE, the compilation fails on python3 due to SETPROCNAME_USE_NONE redefinition. I could possibly work around that, but it's likely helpful to have a way of disabling this completely without it being brittle (i.e. if python3 ever gains the ability to perform this operation). Differential Revision: https://phab.mercurial-scm.org/D6865
author Kyle Lippincott <spectral@google.com>
date Tue, 17 Sep 2019 14:57:42 -0700
parents 763028fc6a69
children d6227c6c0814
files mercurial/cext/osutil.c
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/osutil.c	Sun Sep 22 14:33:56 2019 +0700
+++ b/mercurial/cext/osutil.c	Tue Sep 17 14:57:42 2019 -0700
@@ -765,6 +765,8 @@
 
 #endif /* CMSG_LEN */
 
+/* allow disabling setprocname via compiler flags */
+#ifndef SETPROCNAME_USE_NONE
 #if defined(HAVE_SETPROCTITLE)
 /* setproctitle is the first choice - available in FreeBSD */
 #define SETPROCNAME_USE_SETPROCTITLE
@@ -775,6 +777,7 @@
 #else
 #define SETPROCNAME_USE_NONE
 #endif
+#endif /* ndef SETPROCNAME_USE_NONE */
 
 #ifndef SETPROCNAME_USE_NONE
 static PyObject *setprocname(PyObject *self, PyObject *args)