[PATCH 4 of 4] chg: change server's process title

Jun Wu quark at fb.com
Fri Aug 12 06:18:45 EDT 2016


Excerpts from Yuya Nishihara's message of 2016-08-12 09:26:37 +0900:
> On Thu, 11 Aug 2016 18:28:09 +0100, Jun Wu wrote:
> > Excerpts from Yuya Nishihara's message of 2016-08-12 01:55:44 +0900:
> > > Maybe we'll need setproctitle() equivalent for Linux which will update argv?
> > 
> > That would be probably rewriting argv[0], afaik. I think it is impossible
> > to get the "argv" pointer in a reasonable way.
> 
> Er, Py_GetArgcArgv() ? No idea if we can reliably use this hidden API.
> 
> https://hg.python.org/cpython/file/v2.7.11/Modules/main.c#l691 

Nice find! I did see "static char **orig_argv;" but missed the comment
around it. I'll try the approach. The memory handling could be a bit tricky.

One reason I was using prctl is because it is well defined on Linux, with
the annoying 15-char limit. argv hack is not portable and may have
compatibility issues with other strange code. I will double check with
MRIRuby.

> > > 16-char limitation of prctl() would come from pthread API. If we want to
> > > extend the (ab)use of process title to hgweb, PR_SET_NAME won't be useful.
> > > It won't be displayed in normal ps output.
> > 
> > It's still useful with '-O comm', and atop will record it. prctl is lower
> > level than pthread. Sadly 16 is hardcoded in Linux.
> 
> I assume '-O comm' would be less common for Linux sysadmins.


More information about the Mercurial-devel mailing list