Commit Graph

45 Commits

Author SHA1 Message Date
Craig Small
32b3dafdcd free: Typo fix in error messages
doesn't to don't

References:
 #195

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-03-11 21:45:14 +11:00
Craig Small
c019023e5c free,slabtop,uptime: complain about extra ops
free, slabtop and uptime would happily take extra command line
arguments and doing nothing about them. The programs now check
optind after option processing and will give you usage screen
if there is anything extra.

References:
 procps-ng/procps#181
2020-10-19 22:41:54 +11:00
Jim Warner
1aa8b16441 library: eliminated the questionable 'procps.h' header
There was a time when that procps.h file served a more
traditional role. Prior to the commit referenced below
it held just macros plus manifest constants. But, with
that change, such items were replaced with a series of
includes embracing all the library exported functions.

That approach was known to disguise errors which would
have otherwise yielded a compiler warning. And without
such a warning, there was no way to address the error.

So this patch will trade the all inclusive header file
approach for individual includes only where necessary.

Reference(s):
. April 2016, procps.h header file revamped
commit ccb6ae8de1
. Sept 2018, top abandoned use of procps.h
commit a6dfc2382e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-05 21:13:01 +10:00
Craig Small
fb0915c3ca free: Adjust space to really use 9 chars
@steffhip found that while the translation hint said use 9 characters in
the free headers, it really was only 7.

Currently each line is constructed with the following (in non wide format):
Header + 6 Columns.  The header takes 7 characters and each column is 11
characters wide and prefixed with one space. Thus we have
7 + (1 + 11) * 6 = 79 characters for each line

By dropping the leading space for the first column after the header -the
header is already terminated by a colon- one could indeed provide the needed
9 letters for the header and thus have 9 + 11 * 1 + (1 + 11) * 5 = 80 Chars
per line which would fit into one line.
2020-04-24 17:49:12 +10:00
Jim Warner
30e27d48e9 misc: adapted programs impacted by header file changes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-03-26 19:55:30 +11:00
Jim Warner
f28d605a0d free: fix scaling on 32-bit systems _______ (catch up)
--------------- Original Master Branch Commit Message:
Systems that have a 32-bit long would give incorrect results in free.

References:
 Issue #89
 https://www.freelists.org/post/procps/frees-scale-size-broken-with-32bit-long

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-05-06 07:19:38 +10:00
Craig Small
233b5228be free: Update tests and fix for previous patch
The previous two patches updated free, but needed a tweak and the tests
also needed to be updated. I've hand-calculated the results using bc and
both the testsuite and bc results equal what free prints out.

References:
 commit 9365be7633
 procps-ng/procps#45
2018-01-13 16:12:19 +11:00
getzze
ff700abc72 free.c - name correctly the binary multiples in the human-readable case 2018-01-13 16:12:08 +11:00
getzze
77590f75a1 free.c - correct conversion to decimal multiples 2018-01-13 16:11:59 +11:00
Jim Warner
105de6264c misc: adapt 3 programs to some enum changes, <meminfo>
That preceding commit corrected a little mismanagement
regarding the MEMINFO_MEM_CACHED enumerator, which was
used in the following programs: free, top plus vmstat.

This patch simply adapts those programs to use the new
MEMINFO_MEM_CACHED_ALL enumerator, which reflects both
the 'Cached' plus 'SReclaimable' values they expected.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-06-04 21:36:23 +10:00
Jim Warner
612f36189e related: change for lost 'PROCPS_' enumerator prefixes
With this patch we've completed a progression toward a
standard approach to naming conventions which follows:

* Only functions will begin with that 'procps_' prefix
. ........................................... examples
. procps_vmstat_get ()
. procps_diskstats_select ()
- ----------------------------------------------------

* Exposed structures begin with the module/header name
. ........................................... examples
. struct pids_info
. struct stat_reaped
- ----------------------------------------------------

* Item enumerators begin like structs, but capitalized
. ........................................... examples
. VMSTAT_COMPACT_FAIL
. MEMINFO_DELTA_ACTIVE

[ slabinfo varies slightly due to some item variants ]
. SLABINFO_extra
. SLABS_SIZE_ACTIVE
. SLABNODE_OBJS_PER_SLAB
[ could cure with a prefix of SLABINFO, but too long ]
- ----------------------------------------------------

* Other enumerators work exactly like item enumerators
. ........................................... examples
. PIDS_SORT_ASCEND
. STAT_REAP_CPUS_AND_NODES
- ----------------------------------------------------

* Macros and constants begin just like the enumerators
. ........................................... examples
. #define SLABINFO_GET
. #define DISKSTATS_TYPE_DISK
- ----------------------------------------------------

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-26 20:49:44 +10:00
Jim Warner
d7cbf3448f related: adapt to changes in 'context' structure names
Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-26 20:47:50 +10:00
Jim Warner
338166df57 misc: just eliminate several 'unused' warning messages
[ plus we also play catch up on some earlier changes ]
[ that impacted skill.c, after using --enable-skill! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-26 07:59:48 +10:00
Craig Small
2c5bc47b8e watch,free: interpet intervals in non-locale way
Both watch and free used the locale to determine the required delay
interval for subsequent updates. It's preferable to not care about
locale and accept both 12.34 and 12,34 as meaning 12 seconds and
340 microseconds.

References:
 https://bugs.debian.org/692113

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-03 16:20:48 +10:00
Jim Warner
428ef496a6 misc: adapt others to the changes in 'get' return type
Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-21 20:58:09 +10:00
Jim Warner
d94af0d07a misc: adapted other programs to changes, <MEMINFO> api
This patch just brings *most* other programs into line
with those changes recently made in the <meminfo> API.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-05-12 07:51:10 +10:00
Craig Small
ccb6ae8de1 library: cleanup of library includes
The includes used to define a lot of things a library include
should not. It was also a bit messy what was exposed in the library
and what was not.

get_pid_digits -> procps_pid_length and exported correctly

MALLOC attribute move into relevant .c files
NORETURN attribute moved to relevant .c, not used in library
PURE attribute removed, it wasn't used
KLONG/KLF/STRTOUKL were fixed for long, so now just use long

HIDDEN attribute removed. It was for 3 functions. The PROCPS_EXPORT
seems to do the same (opposite) thing.

likely/unlikely removed from most places, its highly debateable
this does anything useful as CPUs have gotten smarter about branches.

Re-arranged the includes, ALL external programs should just #include
<proc/procps.h> then proc/procps.h includes headers for files that
have exported functions. procps.h and the headers it includes should
not use items that are not exportable (e.g. hidden functions or
macros) they go in procps-private.h
2016-04-16 17:03:57 +10:00
Craig Small
471cf4cd36 Merge branch 'master' into newlib
Conflicts:
	pgrep.c
	proc/sysinfo.c
	ps/output.c
	skill.c
	top/top.c
	top/top.h
	w.c
2015-10-28 21:09:26 +11:00
Craig Small
97cde50b35 free: use correct end sentinel
When scaling values, the last item was integer 0 but the loop checked
for character '0'.

This was reported by 付腾桂 Thanks for the report and patch.
2015-10-24 13:17:36 +11:00
Craig Small
fd007d6d1d free: Parse -s option correctly.
If the -s option was the first option on the command line, free
would report seconds argument failed. This only appeared on the
Debian free, not the one in git.

Closer examination revealed that if a valid float string is
given to strtof() it doesn't set errno to 0, but just leaves it
alone. As we are explicitly testing errno for overflows, this
means the previous errno change is picked up here.

The simple answer is to set errno to 0 before calling strtof().

References:
 https://bugs.debian/org/733758
 https://enc.com.au/2015/08/08/be-careful-with-errno/
2015-08-08 21:04:01 +10:00
Craig Small
05efbebb66 library: Fix up stat API
Adjusted vmstat to use the new API for memory and CPU statistics
2015-06-26 22:37:28 +10:00
Craig Small
f8e98b65ae free: Use IEC units
Free always used 1024 based units but used the confusing old style
kilo,mega etc.

This change changes the names to kibi,mebi for 1024 based divisors
and kilo,mega for 1000 based divisors or IEC units.

It also checks if you try to set two units, e.g free -k -m
Petabyte and Pebibyte have been added.

If you used to use the long options such as --mega these will now
actually print megabytes (they previously printed mebibytes).
The short options are being used on the IEC units

References: https://www.gitorious.org/procps/procps/merge_requests/38

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-04-03 19:18:58 +11:00
Jaromir Capik
c9908b5971 free: fixing the layout broken with the -w introduction
For some reason I thought the columns are left justified
and consequently modified the header incorrectly when
implementing the -w/--wide feature.
With this commit the column width was increased by 1
so that the default layout is 79 characters wide
and allows to display 11 digits per column.
2014-08-20 13:21:22 +02:00
Jaromir Capik
f47001c9e9 free: remove -/+ buffers/cache
With introduction of the 'available' column
and with the latest changes in the 'used' evaluation
the -/+ buffers/cache line became redundant.
The first value duplicates the 'used'
column and the second value has a more accurate
brother called 'available'.
2014-07-31 15:10:42 +02:00
Jaromir Capik
5a0b972ca0 free: replace -a/--available with -w/--wide
This renames the --available switch
to the --wide switch and changes the default
layout so that it includes the 'available'
column and joins buffers and cache into
a common column called 'buff/cache'.
2014-07-31 15:10:42 +02:00
Jaromir Capik
ba6396f886 free: support for MemAvailable
This commit adds a new switch -a/--available that
appends a new column called 'available' to the
output. The column displays an estimation
of how much memory is available for starting
new applications, without swapping. Unlike the data
provided by the 'cached' or 'free' fields, this
field takes into account page cache and also that
not all reclaimable memory slabs will be reclaimed
due to items being in use.
2014-07-11 22:34:06 +02:00
Benno Schulenberg
099bf9a26a Update free text to help translators
Split up the free options so that each option has its own
gettext field, for ease of translating.

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-10-10 09:56:44 +11:00
Rainer Müller
042776e04c configure: check for program_invocation_name
For portabiliy, check for program_invocation_name during configure and
define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is
now enclosed with the appropriate #ifdef block.

The symbol program_invocation_name is only used for error message
handling using error(), so it's safe to omit this if it is not
available.
2013-03-20 16:32:06 +01:00
Adam Sampson
ecc265492f Show sizes > 4G correctly in bytes on 32-bit machines.
size is a long; this needs to be a 64-bit multiplication.
2012-06-27 06:47:38 +10:00
Sami Kerola
52269d22f3 all: check stdout and stderr status at exit
If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code.  The uptime is just an
example same was true with all commands of the project.

$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-23 15:57:53 +01:00
Sami Kerola
ce61089059 docs: clarification to license headers in files
Add license header to all files.  The summary of licensing is below,
taken from Craig Small's email which is referred in commit message
tail.

sysctl and pgrep are GPL 2+
The rest is LGPL 2.1+

Reference: http://www.freelists.org/post/procps/Incorrect-FSF-address-in-the-license-files,8
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=797962
CC: Craig Small <csmall@enc.com.au>
CC: Jaromir Capik <jcapik@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:41:11 +11:00
Sami Kerola
a3544b00f8 free: remove redundant boundary check
The strtol_or_err() already check argument is not larger than
LONG_MAX. This commit also removes clang warning.

free.c:262:55: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
                        if (args.repeat_counter < 1 || args.repeat_counter > ULONG_MAX/2)
                                                       ~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:36:29 +11:00
Craig Small
c84675241d For free -b make the variable a long long
Bug-Debian: http://bugs.debian.org/654368

On systems with very large amonut of RAM when they use the -b or --bytes
option on free you get overflow and free shows a negative amount of
memory, which is obviously wrong.
2012-01-05 09:46:39 +11:00
Craig Small
5219a9c453 Check for 0 repeat count and tests in free
free checks for -c 0 now too.
testsuite has new checks for the checks.
2012-01-04 10:07:31 +11:00
Craig Small
223c95c95d free -c option uses strutils
The handling of the -c (count) option in free uses the standard string
handling and error utils.  The program also checks for negative counts
and errors on these.
2012-01-04 09:53:51 +11:00
Craig Small
fb11e1fe0a Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
2012-01-03 18:48:43 +11:00
Sami Kerola
c3405fab1a translations: group usage texts
Reference: http://www.freelists.org/post/procps/backporting,5
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-02 16:29:03 +11:00
Sami Kerola
0022b6ec5d nls: improve translations and provide translator help comments
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Jim Warner
7b9b0c8d18 free: added remaining missing nls support 2011-12-20 17:30:51 +01:00
Sami Kerola
10db451038 free: add gettext support
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:03 +01:00
Sami Kerola
e1bfc779f4 free: do not mix declarations and code [smatch scan]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:02 +01:00
Sami Kerola
71d10d3a49 name change: procps -> procps-ng
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-04 20:50:12 +02:00
Sami Kerola
d13fbc34a7 free: great modernization
Support long options, use program_invocation_short_name, print
version up on request, new giga & tera byte sizes switches, exit
when numeric arguments has garbage... and for rest see the diff.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-28 10:10:02 +02:00
albert
4ab5a6c8c3 merge with procps2 free 2004-01-30 04:47:14 +00:00
csmall
03a9b5a30f procps 010114 2002-02-01 22:47:29 +00:00