|
|
Log in / Subscribe / Register

±0 on setproctitle

±0 on setproctitle

Posted Oct 7, 2011 23:16 UTC (Fri) by jengelh (subscriber, #33263)
In reply to: +1 on setproctitle by dskoll
Parent article: A Plumber's Wish List for Linux

setproctitle you already have, sort of.

void setproctitle(int argc, char **argv, char *title)
{
    strlcpy(argv[0], title, &argv[argc-1][strlen(argv[argc-1])] - argv[0]);
}
or so is how it is currently done, for the glibc-linux platform.


to post comments

+1 on setproctitle

Posted Oct 8, 2011 15:31 UTC (Sat) by dskoll (subscriber, #1630) [Link] (1 responses)

It's not that easy. Read the source code to some programs that allow changing of the process title (eg, PostgreSQL, Perl, Sendmail.) They all use horrible hacks to get it to work.

+½ on setproctitle

Posted Oct 8, 2011 15:52 UTC (Sat) by jengelh (subscriber, #33263) [Link]

The pgsql code does the same. Plus a handful of extra checks to ensure linearity etc. of course, because it wants to be multi-platform and safe. Now let's rather think about why glibc still does not have the feature (implementing setproctitle via clobbering of argv).


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds