History log of /freebsd-current/lib/libc/gen/setproctitle.c
Revision Date Author Comments
# 559a218c 01-Nov-2023 Warner Losh <imp@FreeBSD.org>

libc: Purge unneeded cdefs.h

These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42385


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# e829181c 18-May-2023 Peter Wemm <peter@FreeBSD.org>

libc: Update copyright text to match current templates.


# 412fd7a3 27-Nov-2021 Konstantin Belousov <kib@FreeBSD.org>

setproctitle_internal(): remove kbuf local, it is write-only

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 46f168bc 31-Jan-2021 Mateusz Guzik <mjg@FreeBSD.org>

Drop temporary compat in setproctitle


# fe258f23 16-Jan-2021 Mateusz Guzik <mjg@FreeBSD.org>

Save on getpid in setproctitle by supporting -1 as curproc.


# 3076591b 15-Apr-2020 Brooks Davis <brooks@FreeBSD.org>

Attempt to use AT_PS_STRINGS to get the ps_strings pointer.

This saves a system call and avoids one of the (relatively rare) cases
of the kernel exporting pointers via sysctl.

As a temporary measure, keep the sysctl support to allow limited
compatability with old kernels.

Fail gracefully if ps_strings can't be found (should never happen).

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D24407


# 8b3c9fac 17-Aug-2018 Mariusz Zaborski <oshogbo@FreeBSD.org>

Fix style nits.


# 78f89679 04-Jul-2018 Konstantin Belousov <kib@FreeBSD.org>

Add setproctitle_fast(3) for frequent callers.

Some applications, notably PostgreSQL, want to call setproctitle()
very often. It's slow. Provide an alternative cheap way of updating
process titles without making any syscalls, instead requiring other
processes (top, ps etc) to do a bit more work to retrieve the data.
This uses a pre-existing code path inherited from ancient BSD, which
always did it that way.

Submitted by: Thomas Munro
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D16111


# 134ede2d 22-Nov-2016 Ed Maste <emaste@FreeBSD.org>

remove unnecessary vm includes from setproctitle

vm headers were needed only for the PS_STRINGS fallback, which was
removed in r297888.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation


# 2cf5e936 18-Apr-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

libc: do not include <sys/types.h> where <sys/param.h> was already included

According to style(9):
> normally, include <sys/types.h> OR <sys/param.h>, but not both.
(<sys/param.h> already includes <sys/types.h> when LOCORE is not defined).


# 63fdc018 12-Apr-2016 Ed Maste <emaste@FreeBSD.org>

Remove PS_STRINGS fallback from setproctitle

In r103767 the kern.ps_strings sysctl was added as the preferred way to
locate the ps_strings struct and is available in any FreeBSD release
supported within the last decade.

Reviewed by: kib


# a22fc066 20-Apr-2015 Konstantin Belousov <kib@FreeBSD.org>

Remove code to support the top of the stack layout for FreeBSD 1.x/2.x
kernel, but keep explanation of the old ps_strings structure to make
it clear what sanity check tries to accomplish.

Noted by: Oliver Pinter <oliver.pinter@hardenedbsd.org>
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 9470460d 01-Jul-2003 Alfred Perlstein <alfred@FreeBSD.org>

Don't segfault if setproctitle(3) is called with NULL initially.
The old buffer was not being initialized and a later str*() op on
it would cause a crash if it wasn't initialized by a previous
call to setproctitle(3) with an actual string.

Noticed by: Ashley Penney <ashp@unloved.org>


# 81781ca0 21-Dec-2002 Rob Braun <bbraun@FreeBSD.org>

Reduce libc's memory footprint by lazily allocating memory used internally
by setproctitle().

Reviewed by: jkh


# 4cd01193 29-Mar-2002 Mark Murray <markm@FreeBSD.org>

Do not use __progname directly (except in [gs]etprogname(3)).
Also, make an internal _getprogname() that is used only inside
libc. For libc, getprogname(3) is a weak symbol in case a
function of the same name is defined in userland.


# ea8d448a 31-Jan-2002 David E. O'Brien <obrien@FreeBSD.org>

Fix SCM ID's.


# 882cdc11 03-Dec-2000 John Polstra <jdp@FreeBSD.org>

When recording the original arguments, stop short if we encounter
a NULL argument. Some programs change the contents of the argv
array, typically to remove some special arguments. They shorten
argv by storing a NULL where an argument pointer used to be. Such
programs core dumped if they called setproctitle(), because it
would try to apply strlen() to a NULL pointer.


# 4113386c 03-Dec-2000 John Polstra <jdp@FreeBSD.org>

When recording the original arguments, don't (ab)use "nargc" for
iterating over the arguments. Doing so wipes out the value which
is about to be stored into the ps_strings structure.


# 305ad8f9 01-Aug-2000 Paul Saab <ps@FreeBSD.org>

If the format string passed to setproctitle begins with a '-'
character, skip the program name when setting the process title.
Ansified with extreme prejudice.

Reviewed by: peter


# 0675e24d 17-Nov-1999 Brian Somers <brian@FreeBSD.org>

Make setproctitle(NULL) restore all of the original arguments
(if it's able).


# b9df5231 16-Nov-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Introduce commandline caching in the kernel.

This fixes some nasty procfs problems for SMP, makes ps(1) run much faster,
and makes ps(1) even less dependent on /proc which will aid chroot and
jails alike.

To disable this facility and revert to previous behaviour:
sysctl -w kern.ps_arg_cache_limit=0

For full details see the current@FreeBSD.org mail-archives.


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# d5297138 16-Dec-1998 Bruce Evans <bde@FreeBSD.org>

Adjust for kern.ps_strings and PS_STRINGS not being a pointer. This is
an unimprovement here. I thought it would be an improvement, as in libkvm,
but here we can access the strings directly.

Use sysctlbyname() instead of sysctl() and trust it to give a nonzero
address if it succeeds.


# ec3a3b45 28-Apr-1998 David Greenman <dg@FreeBSD.org>

Oops, revert part of a diff that wasn't supposed to have been committed.


# 214bed53 28-Apr-1998 David Greenman <dg@FreeBSD.org>

Cache the results of the ps_strings sysctl so that it doesn't have to be
redone for every call of setproctitle().


# 7e546392 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 51295a4d 12-Jul-1996 Jordan K. Hubbard <jkh@FreeBSD.org>

General -Wall warning cleanup, part I.
Submitted-By: Kent Vander Velden <graphix@iastate.edu>


# 7350dd84 24-Feb-1996 Peter Wemm <peter@FreeBSD.org>

If the two recently added sysctl variables exist, use those rather than
the statically compiled PS_STRINGS and USRSTACK variables. This prevents
programs using setproctitle from coredumping if the kernel VM is increased,
and stops libkvm users (w, ps, etc) from needing to be recompiled if only
the VM layout changes.


# 00507771 26-Dec-1995 Peter Wemm <peter@FreeBSD.org>

Bring in an initial version of setproctitle().. This is intended to
replace the dozen other various hacks in the code that do all sorts
of crude things including spamming the envrionment strings with the new
argv string.

This version is mainly inspired by the sendmail version, with a couple of
ideas taken from the NetBSD implementation as well.