Commit graph

35 commits

Author SHA1 Message Date
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Alfonso Gregory a1b6427a97 Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:18 -06:00
Eitan Adler 7275057a5e limits(1): fix always true condition
Reviewed by:	imp
MFC After:	1 week
2018-01-21 08:48:26 +00:00
Eitan Adler 5a9fdfb303 limits(1): add missing break
Reported by:	swildner@DragonFlyBSD.org
MFC After:	1 week
2018-01-20 18:27:00 +00:00
Alan Somers 9039018c34 strcpy => strlcpy, strcat => strlcat
Reported by:	Coverity
CID:		1006703 978863 1006745 1347163
Reviewed by:	cem
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D10192
2017-04-04 19:46:23 +00:00
Konstantin Belousov 250d9fd8aa Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add
login.conf(5) support.

Reviewed by:	jilles
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D5610
2016-03-12 14:54:34 +00:00
Konstantin Belousov 1bdbd70599 Implement process-shared locks support for libthr.so.3, without
breaking the ABI.  Special value is stored in the lock pointer to
indicate shared lock, and offline page in the shared memory is
allocated to store the actual lock.

Reviewed by:	vangyzen (previous version)
Discussed with:	deischen, emaste, jhb, rwatson,
	Martin Simmons <martin@lispworks.com>
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
2016-02-28 17:52:33 +00:00
Konstantin Belousov d2812536e8 Remove the dependency on procfs. Use sysctl KERN_PROC_PATHNAME and
KERN_PROC_PID to obtain the parent process pathname and command, used
to determine the calling shell.

Submitted by:	Stefan Neudorf
PR:	bin/183484
MFC after:	1 week
2013-10-31 09:29:37 +00:00
Konstantin Belousov 4c66d8f978 Fix long line and record proper commit message for r257427:
Add the '-k' option for getopt() call and usage.

Submitted by:	Stefan Neudorf
PR:	bin/183494
MFC after:	1 week
2013-10-31 09:03:42 +00:00
Konstantin Belousov de111151f5 The limit for the swap space is spelled 'swapsize', at least since
tcsh 6.17.00 import.

Submitted by:	Stefan Neudorf
PR:	bin/183480
MFC after:	1 week
2013-10-31 08:58:32 +00:00
Konstantin Belousov 83bce6073a The limit for the swap space is spelled 'swapsize', at least since
tcsh 6.17.00 import.

Submitted by:	Stefan Neudorf
PR:	bin/183480
MFC after:	1 week
2013-10-31 08:22:29 +00:00
Konstantin Belousov 85a0ddfd0b Add a resource limit for the total number of kqueues available to the
user.  Kqueue now saves the ucred of the allocating thread, to
correctly decrement the counter on close.

Under some specific and not real-world use scenario for kqueue, it is
possible for the kqueues to consume memory proportional to the square
of the number of the filedescriptors available to the process.  Limit
allows administrator to prevent the abuse.

This is kernel-mode side of the change, with the user-mode enabling
commit following.

Reported and tested by:	pho
Discussed with:	jmg
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2013-10-21 16:46:12 +00:00
Mikolaj Golub 1d65b4fb8d Add -P option to allow get and set limits for other processes.
Submitted by:	Andrey Zonov <andrey at zonov.org>
MFC after:	2 weeks
2012-01-25 20:14:41 +00:00
Ulrich Spörlein 487ac9ac21 Spelling fixes for usr.bin/ 2011-12-30 11:02:40 +00:00
Xin LI 821df508e8 Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00
Xin LI 6f2d322192 Remove unneeded header includes from usr.bin/ except contributed code.
Tested with:	make universe
2009-12-11 23:35:38 +00:00
Konstantin Belousov c9253e931d Usermode portion of the support for swap allocation accounting:
- update for getrlimit(2) manpage;
- support for setting RLIMIT_SWAP in login class;
- addition to the limits(1) and sh and csh limit-setting builtins;
- tuning(7) documentation on the sysctls controlling overcommit.

In collaboration with:	pho
Reviewed by:	alc
Approved by:	re (kensmith)
2009-06-23 20:57:27 +00:00
Ed Schouten a583eb0809 Add support for RLIMIT_NPTS to limits(1).
After the MPSAFE TTY import we support an additional rlimit, called
RLIMIT_NPTS. This limit allows you to cap the amount of pseudo-terminals
allocated by one user.

We forgot to add support for this limit to limits(1), which means it
crashed. Add the proper bits to make it work like it should.
Unfortunately not all shells actually implement the RLIMIT, so
unfortunately I suspect it to be broken with certain shells.

Submitted by:	Yuriy Tsibizov <yuriy tsibizov gfk ru>
2008-09-02 19:13:24 +00:00
Sean Farley 2966d28c32 Significantly reduce the memory leak as noted in BUGS section for
setenv(3) by tracking the size of the memory allocated instead of using
strlen() on the current value.

Convert all calls to POSIX from historic BSD API:
 - unsetenv returns an int.
 - putenv takes a char * instead of const char *.
 - putenv no longer makes a copy of the input string.
 - errno is set appropriately for POSIX.  Exceptions involve bad environ
   variable and internal initialization code.  These both set errno to
   EFAULT.

Several patches to base utilities to handle the POSIX changes from
Andrey Chernov's previous commit.  A few I re-wrote to use setenv()
instead of putenv().

New regression module for tools/regression/environ to test these
functions.  It also can be used to test the performance.

Bump __FreeBSD_version to 700050 due to API change.

PR:		kern/99826
Approved by:	wes
Approved by:	re (kensmith)
2007-07-04 00:00:41 +00:00
Andrey A. Chernov ba174a5e38 Back out all POSIXified *env() changes.
Not because I admit they are technically wrong and not because of bug
reports (I receive nothing). But because I surprisingly meets so
strong opposition and resistance so lost any desire to continue that.

Anyone who interested in POSIX can dig out what changes and how
through cvs diffs.
2007-05-01 16:02:44 +00:00
Andrey A. Chernov 35e4f24d23 limits calls setenv("name=value", "value", 1); which violates POSIX:
"The setenv( ) function shall fail if:
[EINVAL] The name argument is a null pointer, points to an empty string,
or points to a string containing an '=' character."
The fix (like all others in this subject) is backward-compatible.
2007-04-30 20:10:10 +00:00
Colin Percival 0993d1af06 Use the accepted abbreviation "kB" for kilobyte, rather than "kb" (which
is the common unit for a kilobit).
2004-12-19 13:29:25 +00:00
Brian Feldman 873caac499 Update the usage string in the limits(1) manpage to include -b for
sbsize. Also, correct the format string in getopt(3) usage to reflect
that -b takes an argument, and correct another case of RLIMIT_SBSIZE
having been forgotten.
2002-09-18 16:25:59 +00:00
David E. O'Brien e026a48c34 Consistently use FBSDID 2002-06-30 05:25:07 +00:00
Matthew Dillon 552116c927 Make limits(1) aware of the new vmemoryuse resource limit.
Submitted by:	sheldonh
2002-06-26 03:43:25 +00:00
David Malone 3cd2a58926 Warns cleanups:
1) Add missing initialisers.
2) Avoid shadowing rcswhich.
3) Use intmax_t and %j for printing rather than quad_t and %q.
4) Don't modify a variable twice between sequence points.
2002-04-13 21:28:17 +00:00
Sheldon Hearn 0a39318247 Handle sbsize as a size, not a number.
Submitted by:	Paul Herman <pherman@frenchfries.net>
2001-05-10 17:15:06 +00:00
Philippe Charnier c097456602 Properly use .Nm, .Em, .Pa etc. Make usage() a simplier function. 2000-03-26 14:37:47 +00:00
Brian Feldman 6b3ced11a2 This implements the RLIMIT_SBSIZE ("sbsize") administrative limits for
userland.  Currently, it can be enforced by login and csh.  More
shells supporting sbsize are welcome.
1999-10-09 20:47:59 +00:00
Peter Wemm c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Philippe Charnier 78cad0814f Cosmetic in usage string. Typos in man page. 1997-07-21 12:06:18 +00:00
David Nugent f56bc51b0f login_getclass() -> login_getpwclass().
Updated (incorrect) entry for bash [-v].
Remove unused support for long rlim_t.
Added "bash2" to bash style ulimit handling.
1997-05-10 19:00:58 +00:00
Warner Losh 1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Peter Wemm c115df18cd Revert $FreeBSD$ to $Id$ 1997-02-22 19:58:13 +00:00
David Nugent c03293e593 limits(1): set and display process resources. 1997-01-21 15:05:15 +00:00