Current linux kernels output no more than 32 groups
in /proc/{pid}/status.
Plan is to increase this limit.
This patch allows ps to not core dump if the buffer used to read status
file was too small.
# ps aux
Signal 11 (SEGV) caught by ps (procps-ng version 3.3.3).
ps:display.c:59: please report this bug
Also increases the size of the buffer from 1024 to 4096, since even with
32 groups we are close to the limit.
cat /proc/12731/status | wc
39 128 961
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
When the maj_delta and min_delta fields were added to
the proc_t, they necessitated some compiler generated
padding bytes.
With this slight reordering, those padding bytes are
no longer generated. And since the original commit
already broke the library ABI, now is an opportune
time to correct that misalignment.
Reference:
commit 7753bd1004
Signed-off-by: Jim Warner <james.warner@comcast.net>
Both options provide more information about a process using -X and -XX
flags. The data comes from /proc/PID/smaps so it may vary.
Signed-off-by: Craig Small <csmall@enc.com.au>
In preparation for top scrollable environment display,
the new flag PROC_EDITENVRCVT was added to mirror the
existing single vector string handling for cgroup and
cmdline.
Signed-off-by: Jim Warner <james.warner@comcast.net>
The control group hierarchies for any particular task
could conceivably grow quite large. However, the
library might impose an arbitrary limit of 1024 bytes
via fill_cgroup_cvt.
Two utility buffers of 128 KiB each were already
available for command line use. This commit simply
trades the smaller 1024 byte stack based buffers for
those much larger existing ones. Thus, truncation
can be avoided with no additional run-time costs.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Some inconsistencies have emerged during development
of support for these relatively new proc_t fields.
For example, a PROC_FILLCGROUP flag (via file2strvec)
could return NULL in cgroup whereas PROC_EDITCGRPCVT
(via fill_cgroup_cvt) *almost* guaranteed a return
address (as is true for PROC_EDITCMDLCVT and cmdline).
But even PROC_EDITCGRPCVT could return NULL if the
kernel version was less than 2.6.24. Then with NULL
ps would display a "-" while top would show "n/a".
And while unlikely, with the PROC_FILLSTATUS flag (via
status2proc) a NULL supgid address was theoretically
possible and both ps and top would then show "n/a".
This commit standardizes the following usage:
. PROC_FILLSTATUS (via status2proc)
guarantees a valid supgid address
representing either a true comma
delimited list or "-"
. PROC_FILLCGROUP plus
PROC_EDITCGRPCVT (via fill_cgroup_cvt)
guarantees a cgroup single vector
representing either a true control
group hierarchy or "-"
And as was true before, the following remains true:
PROC_FILLCOM or
PROC_FILLARG (via file2strvec)
may return a NULL cmdline pointer
. PROC_FILLCGROUP (via file2strvec)
may return a NULL cgroup pointer
. PROC_FILLCOM or
PROC_FILLARG plus
PROC_EDITCMDLCVT (via fill_cmdline_cvt)
guarantees a cmdline single vector
representing either a true command
line or a bracketed program name
. PROC_FILLSTATUS plus
PROC_FILLSUPGRP (via supgrps_from_supgids)
guarantees a valid supgrp address
representing either a true comma
delimited list or "-"
Signed-off-by: Jim Warner <james.warner@comcast.net>
There soon will be slab types per cgroup meaning the name of the slab
will have the cgroup name in parathensis after the slab name. This
minor change increases the slab name size to cater for this.
Signed-off-by: Craig Small <csmall@enc.com.au>
Fix the build where it seems a code fix for Linux was likely untested
on other systems.
Define SCHED_BATCH in test-schedbatch, for systems that don't have it;
the corresponding RH BZ#741090 patch used the magic value 3 in output.c
anyway.
Bug-Debian: http://bugs.debian.org/677055
The problem is that in ./proc/sysinfo.c uptime(), it is not
considered that the "savelocale" string is overwritten by the
subsequent call to setlocale(). Hence restoring the locale later on
won't work this way. "savelocale" ought to be a copy of the string
pointed to by setlocale()'s return-value.
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=548711
Backported-by: Sami Kerola <kerolasa@iki.fi>
There have been some internal changes to the library, so the revision
will be incremented for this release. There is no ABI or API changes
so its no real impact.
Both these are from [-Werror=format-security]
sig.c:262:5: error: format not a string literal and no format arguments
global.c:517:3: error: format not a string literal and no format arguments
This patch adds the -p option to the uptime(1) command, which changes
the uptime displayed from something like:
10:35:52 up 2:33, 1 user, load average: 1.69, 1.65, 1.63
to:
up 2 hours, 33 minutes
I originally implemented this as the up(1) program about 14 years ago.
In 2008 or 2009, I created a patch for procps to add this functionality
to uptime and submitted it to the project. Never heard from the
project and no new releases of procps had been made. Then I found out
about this project and decided to port my patch to it. So here it is.
This is really just for fun. There is no real technical reason to
have this functionality. But even now, 14 years later, I still get
emails asking where the source code for up is. So I thought it would
be nice for the uptime command on Linux to sport the up functionality
by default.
Checking for linux kernel version 2.7.0 is meaningless now when 3.0.0
is out.
Reported-By: Christian Hofstaedtler
Bug-Debian: http://bugs.debian.org/635553
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Clean the global list of symbols contain only functions and variables which
are being called from library. The removed symbols are internal for the
library, which means they can be changed without changes to programs using
the library. This clean up should help incoming libprocps clean up work.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Fix the build warnings:
sig.c:227:5: warning: implicit declaration of function 'toupper' [-Wimplicit-function-declaration]
sig.c:231:3: warning: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
On non-linux systems, uts.version provides the version of that
specific kernel (FreeBSD or Hurd version, for example) and not the
emulated procfs pseudo version.
On those systems we need to directly read /proc/version and parse the
string. This change replaces Debian patches gnu-kbsd-version and
complain_unmounted_proc patches.
procps automake defines restrict which means the binaries for procps
binaries compile. However external programs may not of defined
restrict which means they will not complie if they include files found
in /usr/include/proc.
Includes from libc6 use __restrict and if is good enough for
them, its good enough for us.
Some of the latest changes to Makefile.am files are missing.
This patch restores the LOCALEDIR variable, among others,
and dispenses with the include directives in the ps/ and top/
subdirectories since they're no longer needed.
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.
The library used to be called libprocps but it was renamed to make sure
there was only one. However the formatting of the library SONAME has
changed so there cannot be any confusion.
libprocps makes it clear that its a library from this project and not a
set of functions directly on the filesystem.
Re-enable signal number to name string, and other way around,
conversion after it broke at the time when long options where
introduced.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The function will convert a signal number string to a signal name, or
vice a verse. Return value is string, which is an function user is
expected to free after use.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Fix few compiler warnings. Some of these warnings appeared multiple
times, and the listing bellow is more about which sort of errors
where fixed.
devname.c:87:12: warning: comparison of integers of different signs: 'int' and 'unsigned long'
output.c:389:36: warning: passing 'char **const' to parameter of type 'const char *const restrict *' discards qualifiers in nested pointer types
output.c:611:31: warning: comparison of integers of different signs: 'const unsigned long' and 'int'
stacktrace.c:33:37: warning: unused parameter 'signum'
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The devname.h requires readproc.h header which has dev_t. Unless
header is included the includes in program files must be in
correct order. I also added FIXME item to remind that for uid &
gid value int not correct data type but uid_t or gid_t from
pwd.h.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
These xalloc functions are a private function for the library. If using
programs need them, then they should make their own error reporting or
use a common file.
Slackware seems to have this patch, while it is not in use(?) Well,
the upstream procps-ng allows one to disable warnings if that is
wanted. After all having this sort of 'feature' does not cost much,
while lacking it might annoy someone.
A patch from Slackware.
Reference: http://www.ftp.be/packages/slackware/slackware_source/a/procps/procps.nowarning.diff.gz
Backported-by: Sami Kerola <kerolasa@iki.fi>
Conflicts:
proc/ksym.c
Previously the version of libproc always tracked the version of procps.
This doesn't work when other non-procps programs link to the library as
they are always playing catch up.
This change makes the library version independent of the procps version.
It will only be incremented when needed.
Commit a5881b5a4e, addressing
command lines with a trailing space, produced an undesirable
side effect in the fill_cgroup_cvt() function.
This patch restores correct cgroup behavior while still
producing command lines with no trailing space.
When PROC_FILLARG was used (invoking file2strvec)
command lines contained no trailing space.
When PROC_EDITCMDLCVT was used (invoking read_unvectored)
command lines contained a trailing space.
Now both routes to a cmdline act the same -- no trailing space.
The CodingStyle document suggests programs should allow for
cmdlines of at least 128k. Only the ps program can display
such a cmdline, and only with multiple -w switches.
The library function file2strvec can essentially return
a cmdline of unlimited length. However, the library function
fill_cmdline_cvt used an arbitrary upper limit of 2048 for
buffers automatically allocated on the stack.
This patch raises the fill_cmdline_cvt upper limit to 128k via
dymaically acquired utility buffers ensured by the openproc
function.
It also makes indentation consistent in the openproc function.
There were numerous library memory allocation inconsistencies.
Some were checked for failure and others were not.
All library source modules were modified to utilize the alloc.h
memory rouines which are consistent in dealing with errors.
A callback provision in the form of xalloc_err_handler
(of type message_fn) was added to the alloc module.
This change allowed a program like top, who alters the
termios structure, to override the default fprint(stderr...)
behavior in the event of an error.
The new function xstrdup was also added for symmetry.
configure.ac now set to 3.3.1
vmstat -p has not worked for a long time, this applies Debian patch
vmstat_part_format, the details:
Author: Daniel Novotny
Description: The contents of /proc/diskstats have changed since 2.6.25
Changed PATH_MAX to 32 because its missing on hurd
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=485243
Bug-Debian: http://bugs.debian.org/588677
Last-Update: 2010-11-17
Notice that contents of file library.map file are almost certainly
wrong as it is making everything exported.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
For the small number of devices that we cannot get Hertz out of ELF
notes but the cpu numbers make sense (ie not kFreeBSD) there is a hack
by using the CPU numbers. The problem is there was 4 numbers, now there
are 7. This fixes the hack by adding all 7 to get a more correct number.
This is from Debian patch sysinfo_7_numbers
Bug-Debian: http://bugs.debian.org/460331
FreeBSD has no good way of finding the Hertz value. ELF notes don't
work, you can't find it in a function and even asm/params.h does
not have it. Lucky for us, it is always 100.
Based upon Debian patch patch sysinfo_kfreebsd_hertz by Petr Salinger
Bug-Debian: http://bugs.debian.org/460331
Caution, 460331 has lots of overlapping bugs all around the Hertz
problem across many arches.
Suppresses a message about elf notes not found on non-Linux systems.
kFreeBSD systems, for one, don't have this so the message appears
every time you run a procps program otherwise.
Based upon Debian patch sysinfo_elfnote by Petr Salinger
Bug-Debian: http://bugs.debian.org/378157
The library file version string is taken from configure.ac AC_INIT.
Reference: http://www.freelists.org/archive/procps/09-2011
Signed-off-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Craig Small <csmall-procps@enc.com.au>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
ps
. added tgid support
. made process/task naming consistent
top
. added tgid support
. standardized pid related width logic
documents
. added tgid to ps & top man documents
library
. fixed OOMEM_ENABLE readtask bug
. corrected header typo for tgid
Library changes
readproc
. added readeither to more efficiently
fill both process and thread proc_t
. added readproctab3, uses readeither
. included task path support in:
fill_cgroup_cvt, fill_cmdline_cvt,
read_unvectored
. QUICK_THREADS #define allows copying
process info vs. repeatedly reading
. simple_nexttid no longer values ppid
. path var made non-static in readtask
. documented 'proc_data_t' in .h file
. tweaked some c comments & formatting
library.map
. added new readeither, readproctab3
Program changes
ps
. exploits readproctab3 where possible
. improved args/comm compliance
top
. exploits readeither
Library changes
readproc
. added support for supplementary groups
. eliminated 2 potential mem leak sources
. shortcut used for multi-threaded str
vectors & ptrs was obsoleted
. freeing of proc_t related dynamic
memory now rests with the library
. standardized/normalized many c comments
sysinfo
. corrected note regarding glibc & cpuinfo
library.map
. made the visible freeproc accessable
Program changes
pmap
. initialized buffer for new readproc i/f
. eliminated now obsolete free() call
ps
. added width aware supgrp support
. initialized buffers for new readproc i/f
. eliminated now obsolete free() calls
top
. added supgrp support as variable width
. eliminated now obsolete free() calls
. expoilted library freeproc function
. corrected -h|v args text & spacing
. updated some c comments
Documentation changes
ps.1
. added supgid and supgrp
top.1
. added supgid and supgrp
. addition of above required renumbering
many fields in section 3a. DESCRIPTIONS
For some reason necessary variable was commented out at June
2003, see commit bellow for details.
commit 5c99a21b72
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This will revert change at Oct 2002 when autotools support was
removed.
Unlike before the package developers are expected to use
./autogen.sh to generate ./configure script, and run make after
that. The build system is also able to create, with make dist, a
tar ball release which compiles correctly, and has files which
seemed to be important to have.
The patch removes few unnecessary files, but no everything. Files
procps.lsm and procps.spec in git repository are useless as is,
but I left them lying around for someone who can make more
justified call about removal of them.
Last, but not least package version number is set 3.3.0 to
distinct this procps from the sourceforge's upstream procps.
Please notice that libproc relese is kept as 3.2.8.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Library Changes
. added PROC_EDITCMDLCVT flag
. added an internal (static) fill_cmdline_cvt function:
- reads and "escapes" /proc/#/cmdline
- returns result as a single string in a single vector
- callers are guaranteed a cmdline (no more NULL)
. added vectorize_this_str function, exploited by
fill_cgroup_cvt, fill_cmdline_cvt
. generalized read_cmdline function as read_unvectored, now
exploited by fill_cgroup_cvt, fill_cmdline_cvt, read_cmdline
( cgroup and cmdline no longer need be converted to string )
( vectors before being transformed to final representation )
. fixed bug regarding skipped group numbers (when enabled)
. escape_str made responsible for all single byte translation
with distinction between control chars + other unprintable
. added escaped_copy function for already escaped strings
. reorganized parts of proc_t to restore formatting standards
( displacement changes shouldn't matter with new version # )
. former ZAP_SUSEONLY #define now OOMEM_ENABLE
. added to library.map: escaped_copy; read_cmdline
Top Program Changes
. exploited the new PROC_EDITCMDLCVT provision
. eliminated now obsolete #include "proc/escape.h"
. changed the P_WCH display format if no kernel symbol table
. fixed very old bug in lflgs for out-of-view sort fields
. former ZAP_SUSEONLY #define now OOMEM_ENABLE
Ps Program Changes
. exploited the new PROC_EDITCMDLCVT provision
. exploited the new escaped_copy function
. consolidated pr_args and pr_comm into pr_argcom
Signed-off-by: Jan Görig <jgorig@redhat.com>
This source patchset addresses the following:
Library Extension (readproc)
. added PROC_EDITCGRPCVT flag
. added an internal (static) fill_cgroup_cvt function:
. reads AND parses /proc/#/cgroup
. returns result as a single string in a single vector
. thus no changes to proc_t structure or free memory logic
Program Enhancements (top)
. removed parse_cgroup logic in favor of libproc
. eliminated cgroup sort recurring overhead
. converted WCHAN field to variable width
. generalized variable width field logic in task_show
. real-time notation under P col more distinctive as 'rt'
Program Cosmetic (top)
. CGROUP now known as CGROUPS (plural)
. moved jan's attribution from top.c to 'Notes' in top.h
. numerous comments tweaked
Document Enhancements (top)
. documented CGROUPS field (required renumbering all fields)
. adapted narratives for the 3 current variable width fields
. expanded real-time scheduling notes, 'RT' now shown as 'rt'
Signed-off-by: Jan Görig <jgorig@redhat.com>
Having one constructor depend on another means if the order
is reversed you get a different result.
Patched based on idea by Tom Evans.
Added new code to old_Hertz_hack by Werner Fink <werner@suse.de>
Bug-Debian: http://bugs.debian.org/460331
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=632236
Reviewed-by: Jan Görig <jgorig@redhat.com>
Read the time of system boot from /proc/stat (entry: btime) instead
of computing it as the difference between the current time and the
uptime. This is the only way to get a consistent result which won't
possibly change from one run to the next.
The problems with the original code were:
* Both the current time and the uptime are rounded down to the second,
but the system doesn't boot on an integer second value so they do not
tick at the same moment. Thus, the rounding errors can cause a one
second difference from one run to the next.
* We can't read the uptime and the current time at the exact same moment
anyway, so the time difference we compute is bound to be inaccurate.
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=222251
Author: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Craig Small <csmall@debian.org>