[ovs-dev] Changing proc title on FreeBSD

Ed Maste emaste at freebsd.org
Wed Oct 10 13:34:29 UTC 2012


On 9 October 2012 18:07, Ben Pfaff <blp at nicira.com> wrote:
> On Tue, Oct 09, 2012 at 06:03:32PM -0400, Ed Maste wrote:
>>...
>>
>> Interesting - I didn't notice this code before.
>>
>> On FreeBSD we have setproctitle(const char *fmt, ...) for this
>> functionality, which has the same interface as proctitle_set.
>> Unfortunately there's no decent way to pass the varargs through.
>>
>> I could add an #elif defined(__FreeBSD__) case to command-line.c and
>> use a temporary buffer in my proctitle_set implementation, or could
>> just #define proctitle_set setproctitle in command-line.h.  Thoughts
>> on which is preferable?
>
> I'm happy enough with the latter; it's simpler, as long as it works.

Ahh, so there's one small caveat.  setproctitle internally prepends
the "program_name: " to the provided string so the resulting proctitle
ends up like:

    ovs-vswitchd: ovs-vswitchd: worker process for pid 24853 (ovs-vswitchd)

The current proctitle_set callers already use this format and it seems
to be a reasonable restriction, so it would be possible to move the
program_name logic into proctitle_set for Linux as well.  If that's
undesirable I'll use temporary buffer in the FreeBSD implementation
and strip the program name back off before calling setproctitle.



More information about the dev mailing list