Yeah, I can call prctl through ctypes, but I can't modify argv[0] through ctypes. According to the SO link, it seems that the latter is necessary for some forms of `ps` to display the new name.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I spent a little time poking around with this. I haven't found a solution, but i'm fairly convinced one exists, using ctypes to call functions in Python.h.
You should be able to get a reference to argv from Py_GetArgcArgv, and pass that through to strcpy (or a variant).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
John: can you confirm whether your deployment Python version has access to the "ctypes' module?
Yep. The only scenarios in which we're using finitd are python >=2.6.
Based on what I can find, I can do a *partial* rename using ctypes, but to do a full rename requires a C module, e.g., http://code.google.com/p/procname/ , which is written fairly poorly but should work. See http://stackoverflow.com/questions/564695/is-there-a-way-to-change-effective-process-name-in-python for more details.
Presumably by a "partial" rename you mean a prctl rename, right? I have to think that the strcpy method would be doable using ctypes, too.
Yeah, I can call prctl through ctypes, but I can't modify argv[0] through ctypes. According to the SO link, it seems that the latter is necessary for some forms of `ps` to display the new name.
I spent a little time poking around with this. I haven't found a solution, but i'm fairly convinced one exists, using ctypes to call functions in Python.h.
You should be able to get a reference to argv from Py_GetArgcArgv, and pass that through to strcpy (or a variant).