polybar-scripts: [info-softwarecounter.py] process ID out of range for gnome-builder

I’ve noticed that I have an error message when I open gnome-builder which says error: process ID out of range, this is strange because according to /proc/sys/kernel/pid_max:

$ cat /proc/sys/kernel/pid_max
4194304

$ ps aux | grep "builder\|^U"
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
jfernan+  420762  0.0  0.0   2424   672 ?        S    16:58   0:00 bwrap --args 31 gnome-builder
jfernan+  420770  0.0  0.0   2784  1544 ?        S    16:58   0:00 bwrap --args 31 gnome-builder
jfernan+  420771  6.3  1.1 102097972 158948 ?    Sl   16:58   0:10 gnome-builder
jfernan+  420855  0.3  0.1 149216 21844 ?        Ssl  16:58   0:00 /app/libexec/gnome-builder-git
jfernan+  420927  1.5  1.0 313940 154220 ?       Ssl  16:58   0:02 /app/libexec/gnome-builder-clang
jfernan+  422466  0.0  0.0   8916  2456 pts/1    S+   17:00   0:00 grep builder\|^U

The process ID is in range, so could this be a problem with subprocess python module? I would like in fact to add gnome-builder to the vims tuple in the dict, but it has not any effect because of the error message. This is the traceback

error: process ID out of range

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).
Traceback (most recent call last):
  File "/home/jfernandez/dotfiles/polybar/.config/polybar/polybar-scripts/./info-softwarecounter.py", line 81, in <module>
    gui_counts = Counter(get_running_guis())
  File "/home/jfernandez/dotfiles/polybar/.config/polybar/polybar-scripts/./info-softwarecounter.py", line 74, in get_running_guis
    validprocs = [
  File "/home/jfernandez/dotfiles/polybar/.config/polybar/polybar-scripts/./info-softwarecounter.py", line 75, in <listcomp>
    get_process(w[2]) for w in wlist if check_wtype(w[0]) == True
  File "/home/jfernandez/dotfiles/polybar/.config/polybar/polybar-scripts/./info-softwarecounter.py", line 69, in get_process
    proc = get(["ps", "-p", w_id, "-o", "comm="])
  File "/home/jfernandez/dotfiles/polybar/.config/polybar/polybar-scripts/./info-softwarecounter.py", line 61, in <lambda>
    get = lambda cmd: subprocess.check_output(cmd).decode("utf-8").strip()
  File "/usr/lib/python3.9/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ps', '-p', '0', '-o', 'comm=']' returned non-zero exit status 1.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Just to confirm, it worked with that code code change, right? I’ll submit a PR in a sec.

Yeh, I noticed the PID 4 before, it does look suspicious. Maybe there is some PID linux documentation. Also, I guess I don’t even need to use the PID in the code, maybe I should’ve just used the last column there… i.e. checked for "Builder - Open a Project" or "General - Discord". I guess the code could be improved.

On line 75, does this work: get_process(w[2]) for w in wlist if check_wtype(w[0]) == True and w[2] != '0'