A difference in behaviour between the sysvinit and procps pidof
was that the procps one would sometimes not find process that
the sysvinit one did.
The difference is that if a space is found in argv[0] then sysvinit
would look at cmd for a match. This isn't perfect and more of a
best guess but does often work.
procps pidof now follows the same "standard". The most obvious
difference is with kde based processes and incoming ssh connections
with sshd.
References:
Commit 3f5b75035e
GitLab issue #4https://gitlab.com/procps-ng/procps/issues/4https://github.com/limingth/sysvinit/blob/master/sysvinit-2.88dsf/src/killall5.c#L800
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
As an additional test of the viability of the new pids
API, the pidof program has now been converted. As part
of that effort, several library changes were prompted:
. individual reads were added as an alternative to the
all encompassing (maybe over broad?) 'reap' provision.
. an alternate version of cgroup, cmdline plus environ
has been added to represent actual vectorized strings.
Signed-off-by: Jim Warner <james.warner@comcast.net>
The function pid_link tries to handle programs which contain very
long paths to their executables. If 1024 bytes are not enough to
contain the path, the loop wants to get more and more space until
the path can fit.
The loop's condition does not fit though.
readlink will never return a value higher than its supplied size
limit, which is "path_alloc_size - 1", therefore the loop-check of
"len == path_alloc_size" will always be false: the loop will never
be repeated.
While at it, the if-condition inside the loop's body can be omitted,
because it is always true.
Benno Schulenberg suggested some changes to the help messages
to provide some consistency and clarity for both the users and
translators of procps.
The test needed to be updated as the pmap output changed too.
Signed-off-by: Craig Small <csmall@enc.com.au>
To assist translators, the help lines are split so that each translation
chunk has one option. This gives bonus of if we add or change an option,
only that option remains untranslated rather than the entire help block.
Reference:
http://www.freelists.org/post/procps/procpsng-for-Translation-Project,1
Signed-off-by: Craig Small <csmall@enc.com.au>
This commit introduces support for special %PPID value that
can be passed to the -o option as a substitution for parent
PID. It also allows users to use two additional separators
for omitted PIDs - colon and semicolon.
As the sysvinit becomes obsolete, some of the bundled tools
need to find a new home. The procps-ng project seems to be
the most suitable project for adopting the pidof tool.
This commit introduces a redesigned version of pidof
that satisfies the LSB requirements.
In corner cases the behaviour might differ from the former
one as the new version doesn't use any stat(2) calls.