Coder Social home page Coder Social logo

procps's Issues

pgrep: `--terminal` without pattern fails

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

pgrep: --list-full doesn't show anything after the PID if `/proc/<PID>/cmdline` is empty

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

free: implement `--human`

-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: -o/-n fail if pattern doesn't match

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.

Add command `top`

could i implement ps and top for this, also there already exist projects like bottom

Typo in "About" text

Currently, the "About" text of the project is:

Rust reimplemtation of the procps project

It should be reimplementation instead of reimplemtation.

Implementing a more generalized `proc` pseudo-filesystem abstraction for multiple platforms

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.

  • FreeBSD's proc pseudo-fs is not automounted.
  • macOS does not have a proc fs, it use sysctl instead.
  • Windows platform are much different from *NIX family.

`watch`: implement `--interval`

      -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).

Dependency Dashboard

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.

Detected dependencies

cargo
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-actions
.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

  • Check this box to trigger a request for Renovate to run again on this repository

free: incorrect `CachUse` value with `--line --wide`

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

pidof: support multiple PIDs with `-o`

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

free: implement `--wide`


       -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.

Add command `pgrep`

       pgrep - look up, signal, or wait for processes based on
       name and other attributes

pgrep: should show an error message if pattern is longer than 15 chars and there's no match

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: `--terminal` doesn't support `?` as value

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

free: implement the different size display

      -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.

`w`: GNU w output header includes output from uptime

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.

free: implement `--line`

       -L, --line
              Show output on a single line, often used with the -s option to show memory  statis-
              tics repeatedly.

ps: Fix the `time` code

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 

free: `used` miscalculation

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.