uutils / procps Goto Github PK
View Code? Open in Web Editor NEWRust reimplementation of the procps project
License: MIT License
Rust reimplementation of the procps project
License: MIT License
pgrep - look up for processes based on name and other at-
tributes
When using --terminal
without a pattern, our implementation fails whereas pgrep
from procps-ng works fine:
$ cargo run pgrep --terminal=tty1
pgrep: no matching criteria specified
Try `pgrep --help' for more information.
$ pgrep --terminal=tty1
750
pidof - find the process ID of a running program
ps - report a snapshot of the current processes.
-t, --total
Display a line showing the column totals.
When using --list-full
, our pgrep
doesn't show anything after the PID if the corresponding /proc/<PID>/cmdline
is empty whereas pgrep
from procps-ng
shows the process name inside square brackets. For example:
$ pgrep -a k
...
7067 /usr/bin/konsole
7101 /usr/bin/konsole
7122 /usr/bin/konsole
7146 /usr/bin/konsole
8424 [kworker/3:0-i915-unordered]
13139 [kworker/u16:4-events_power_efficient]
13141 [kworker/u16:6-events_unbound]
13142 [kworker/u16:7-events_unbound]
14186 [kworker/u16:0-events_unbound]
$ cargo run pgrep -a k
...
7067 /usr/bin/konsole
7101 /usr/bin/konsole
7122 /usr/bin/konsole
7146 /usr/bin/konsole
8424
13139
13141
13142
14186
-h, --human
Show all output fields automatically scaled to shortest three digit unit and dis-
play the units of print out. Following units are used.
B = bytes
Ki = kibibyte
Mi = mebibyte
Gi = gibibyte
Ti = tebibyte
Pi = pebibyte
If unit is missing, and you have exbibyte of RAM or swap, the number is in
tebibytes and columns might not be aligned with header.
It's already partially implemented. What's missing is the "scaled to shortest three digit unit" functionality.
pgrep
currently fails when specifying a non-matching pattern with -o
or -n
:
$ cargo run pgrep -o non_matching
thread 'main' panicked at src/uu/pgrep/src/pgrep.rs:220:34:
called `Option::unwrap()` on a `None` value
$ cargo run pgrep -n non_matching
thread 'main' panicked at src/uu/pgrep/src/pgrep.rs:218:35:
called `Option::unwrap()` on a `None` value
The expected behavior is no output and an exit code of 1
.
could i implement ps and top for this, also there already exist projects like bottom
Currently, the "About" text of the project is:
Rust reimplemtation of the procps project
It should be reimplementation
instead of reimplemtation
.
vmstat - Report virtual memory statistics
snice - report process status
In order to cope with multi-platform support and handle different implementations of multiple platforms, it is necessary to abstract different implementations of multiple platforms
The current proc
implementation is a Linux-only implementation and relies heavily on the proc
pseudo-filesystem - it needs to read inside the /proc
filesystem.
sysctl
instead. pidwait - wait for processes based on name and other attributes
-n, --interval seconds
Specify update interval. The command will not allow quicker than 0.1 second inter-
val, in which the smaller values are converted. Both '.' and ',' work for any lo-
cales. The WATCH_INTERVAL environment can be used to persistently set a non-default
interval (following the same rules and formatting).
slabtop - display kernel slab cache information in real time
-s, --short
Use the short format. Don't print the login time, JCPU or PCPU times.
They have been disabled here:
https://github.com/uutils/procps/pull/49/files
-c, --count count
Display the result count times.
-l, --lohi
Show detailed low and high memory statistics.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
Cargo.toml
pretty_assertions 1.4.0
rlimit 0.10.1
uucore 0.0.27
clap 4.5.4
clap_complete 4.5.2
clap_mangen 0.2.20
regex 1.10.4
sysinfo 0.31.0
libc 0.2.154
phf 0.11.2
phf_codegen 0.11.2
textwrap 0.16.1
thiserror 1.0.63
xattr 1.3.1
tempfile 3.10.1
rand 0.8.5
bytesize 1.3.0
chrono 0.4.38
walkdir 2.5.0
prettytable-rs 0.10.0
nix 0.29
src/uu/free/Cargo.toml
src/uu/pgrep/Cargo.toml
src/uu/pidof/Cargo.toml
src/uu/pmap/Cargo.toml
src/uu/ps/Cargo.toml
src/uu/pwdx/Cargo.toml
src/uu/slabtop/Cargo.toml
src/uu/w/Cargo.toml
src/uu/watch/Cargo.toml
.github/workflows/ci.yml
actions/checkout v4
actions/checkout v4
actions/checkout v4
actions/checkout v4
codecov/codecov-action v4
.github/workflows/code-quality.yml
actions/checkout v4
Swatinem/rust-cache v2
actions/checkout v4
Swatinem/rust-cache v2
mozilla-actions/sccache-action v0.0.5
nick-fields/retry v3
With procps free
, the values returned with --line
and --line --wide
are very similar:
$ free --line
SwapUse 0 CachUse 3406128 MemUse 3489132 MemFree 1997776
$ free --line --wide
SwapUse 0 CachUse 3406324 MemUse 3481656 MemFree 2005052
With uutils free
, on the other hand, there is a significant decrease in the CachUse
value with --line --wide
:
$ cargo run free --line
SwapUse 0 CachUse 3415656 MemUse 3492068 MemFree 1992516
$ cargo run free --line --wide
SwapUse 0 CachUse 360556 MemUse 3536136 MemFree 1948428
pkill - signal for processes based on name and other attributes
The original pidof
allows the user to specify multiple PIDs with -o
whereas our pidof
doesn't allow it.
$ pidof -o1282,5304 konsole
6531 6507 6482
$ cargo run pidof -o1282,5304 konsole
error: invalid value '1282,5304' for '-o <omitpid>': invalid digit found in string
-w, --wide
Switch to the wide mode. The wide mode produces lines longer than 80 characters. In
this mode buffers and cache are reported in two separate columns.
-h, --no-header
Don't print the header.
pgrep - look up, signal, or wait for processes based on
name and other attributes
$ cargo run free --kilo
total
Mem: 8024772
$ cargo run free --kibi
total
Mem: 8024772
$ free --kilo
total
Mem: 8217366
$ free --kibi
total
Mem: 8024772
The original pgrep
shows an error message if the specified pattern is longer than 15 chars whereas our pgrep
doesn't.
$ pgrep 123456789012345
$ pgrep 1234567890123456
pgrep: pattern that searches for process name longer than 15 characters will result in zero matches
Try `pgrep -f' option to match against the complete command line.
$ cargo run pgrep 123456789012345
$ cargo run pgrep 1234567890123456
pgrep
from procps-ng supports ?
as a value for --terminal
to match processes that do not have a controlling terminal. Our implementation doesn't support this value.
$ pgrep --terminal=? konsole
1265
1599
1640
1681
1741
$ cargo run pgrep --terminal=? konsole
// no output
-x, --extended
Show the extended format.
w
from procps-ng uses spaces as column delimiters whereas uutils w
currently uses tabs.
-b, --bytes
Display the amount of memory in bytes.
-k, --kibi
Display the amount of memory in kibibytes. This is the default.
-m, --mebi
Display the amount of memory in mebibytes.
-g, --gibi
Display the amount of memory in gibibytes.
--tebi Display the amount of memory in tebibytes.
--pebi Display the amount of memory in pebibytes.
--kilo Display the amount of memory in kilobytes. Implies --si.
--mega Display the amount of memory in megabytes. Implies --si.
--giga Display the amount of memory in gigabytes. Implies --si.
--tera Display the amount of memory in terabytes. Implies --si.
--peta Display the amount of memory in petabytes. Implies --si.
-h, --human
Show all output fields automatically scaled to shortest three digit unit and dis-
play the units of print out. Following units are used.
B = bytes
Ki = kibibyte
Mi = mebibyte
Gi = gibibyte
Ti = tebibyte
Pi = pebibyte
If unit is missing, and you have exbibyte of RAM or swap, the number is in
tebibytes and columns might not be aligned with header.
The header in GNU version contains the output from uptime as part of the header.
15:12:54 up 5:47, 1 user, load average: 0.68, 0.61, 0.74
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
coreutils already has an implementation for uptime so the code for this already exists.
tload - graphic representation of system load average
-L, --line
Show output on a single line, often used with the -s option to show memory statis-
tics repeatedly.
Except:
❯ ps
PID TTY TIME CMD
16643 pts/1 00:00:03 zsh
16660 pts/1 00:00:00 zsh
16733 pts/1 00:00:00 zsh
16734 pts/1 00:00:00 zsh
16736 pts/1 00:00:00 gitstatusd-linu
117274 pts/1 00:00:00 ps
But:
❯ cargo run ps
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.85s
Running `target/debug/procps ps`
PID TTY TIME CMD
16643 pts/1 00:00:00 zsh
16660 pts/1 00:00:00 zsh
16733 pts/1 00:00:00 zsh
16734 pts/1 00:00:00 zsh
16736 pts/1 00:00:00 gitstatusd-linu
116825 pts/1 00:00:00 procps
skill - send a signal
Here's procps free
's outputs
total used free shared buff/cache available
Mem: 32273048 9797636 15312152 200600 7826228 22475412
Swap: 0 0 0
Here's uutils free
's outputs
total used free shared buff/cache available
Mem: 32273048 16985112 15287936 199512 7825372 22451428
Swap: 0 0 0
The original pidof
returns a PID for each specified program name whereas our pidof
returns a single PID.
$ pidof -s bash bash bash
9024 9024 9024
$ cargo run pidof -s bash bash bash
9024
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.