s3-daemons: Set the comment field of the daemons.

Andrew Bartlett abartlet at samba.org
Wed Mar 6 02:11:11 MST 2013


On Wed, 2013-03-06 at 09:36 +0100, Andreas Schneider wrote:
> On Wednesday 06 March 2013 19:03:31 Andrew Bartlett wrote:
> > On Wed, 2013-03-06 at 01:17 +0100, David Disseldorp wrote:
> > > commit f06a0352e551ea125675659923c909d6d4c473fd
> > > Author: Andreas Schneider <asn at samba.org>
> > > Date:   Mon Feb 25 10:41:18 2013 +0100
> > > 
> > >     s3-daemons: Set the comment field of the daemons.
> > >     
> > >     PR_SET_NAME sets the comm field of a process. This way we can give
> > >     processes a name and they are easier to identify.
> > >     
> > >     $ ps afx -o pid,comm
> > >     29447 smbd
> > >     29452  \_ epmd
> > >     29453  \_ lsasd-master
> > >     29455  |   \_ lsasd-child
> > >     29457  |   \_ lsasd-child
> > >     29459  |   \_ lsasd-child
> > >     29461  |   \_ lsasd-child
> > >     29463  |   \_ lsasd-child
> > >     29454  \_ spoolssd-master
> > >     29456      \_ lpqd
> > >     29458      \_ spoolssd-child
> > >     29460      \_ spoolssd-child
> > >     29462      \_ spoolssd-child
> > >     29465      \_ spoolssd-child
> > >     29466      \_ spoolssd-child
> > >     29467      \_ spoolssd-child
> > >     29468      \_ spoolssd-child
> > >     29469      \_ spoolssd-child
> > >     29470      \_ spoolssd-child
> > >     29471      \_ spoolssd-child
> > >     
> > >     Reviewed-by: David Disseldorp <ddiss at samba.org>
> > 
> > G'Day,
> 
> Hi Andrew,
> 
> > Can you handle all the other callers to setproctitle also please?
> > 
> > Ideally we would have one function call that calls both of these
> > (setproctitle is a no-op on Linux), to mean 'try as hard as you can to
> > name this process.
> 
> https://git.samba.org/?p=asn/samba.git;a=shortlog;h=refs/heads/s3-fixes
> 
> I've added that now so that setproctitle is used if available. However we have 
> a problem here. PR_SET_NAME is limited to 16 chars (including \0) and 
> setproctitle obviously allows more.
> 
> So I can't replace the calls in s4 cause they are much bigger. The next thing 
> is that prctl needs to point to a static string.

I've looked over the setproctitle calls, and I think the right approach
is to provide a truncated 16 char string, and then also the printf()
string to setproctitle (defaulting to the same string if NULL).

prctl_set_comment_and_title(const char *short_name, const char
*long_name, ...) 

I think we should just put the static string into this function, and
truncate there if the caller supplies more.  We should document both
that, and the 16 char limitation and replace all setproctitle() calls.

That should mean we get something in all callers - such as a task name
like ldapsrv - and possibly something quite descriptive on platforms
like FreeBSD. 

What do you think?

Andrew Bartlett

-- 
Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org




More information about the samba-technical mailing list