Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]:The terminal returns a strange string #221

Closed
ghost opened this issue Jan 1, 2022 · 12 comments
Closed

[Bug]:The terminal returns a strange string #221

ghost opened this issue Jan 1, 2022 · 12 comments

Comments

@ghost
Copy link

ghost commented Jan 1, 2022

Command execution:
procs | procs

The terminal returns:
11;rgb:0e0e/1010/1919

Screenshot:
IMG_20220102_003137

@ghost ghost changed the title Strange string appears in procs The terminal returns a strange string Jan 1, 2022
@ghost ghost changed the title The terminal returns a strange string [Bug]:The terminal returns a strange string Jan 1, 2022
dalance added a commit that referenced this issue Jan 18, 2022
@dalance
Copy link
Owner

dalance commented Jan 18, 2022

I fixed it, and released v0.12.0.

@Saduff
Copy link

Saduff commented Jan 20, 2022

I still have this issue using v0.12.0 over SSH. In my case, it happens with any procs command such as procs whatever. It's weird though, only seems to happen over SSH:

  • localhost - no issue
  • SSH into localhost - no issue
  • SSH into server and execute procs whatever - issue is there
  • same thing using "physical" terminal (tty1) via server's IPMI - no issue
  • SSH into another server - issue is there

Not sure if it has something to do with my setup or not. Tried different terminal emulators (kitty, xfce terminal) and shells (zsh, bash), but same results.

@dalance
Copy link
Owner

dalance commented Jan 24, 2022

@Saduff Could you provide the information about your SSH server / client and OS? I can't reproduce it.

@Saduff
Copy link

Saduff commented Jan 24, 2022

Client and server are both running Arch Linux. Client is running kernel 5.16.2, server is running 5.14.12. Both client and server are running OpenSSH 8.8p1, procs is installed from the Arch repo.

Thought it might have something to do with SSH multiplexing on the client-side as I have that turned on with this config:

ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
ControlPersist 10m

But disabling that made no difference. I also had X11 forwarding turned on with ForwardX11 yes, but disabling that made no difference either.

I could not reproduce it by SSHing into an archlinux docker container running locally. However, the issue is there when running procs inside the docker container on the server (over SSH). To be clear, the SSH connection is between my local machine and the server and then I simply ran procs inside the container.

@dalance
Copy link
Owner

dalance commented Jan 25, 2022

How about more information about the docker container?
I tried archlinux:latest, but it can't be reproduced.

  • Server side
$ docker run -it --rm --entrypoint /bin/bash archlinux:latest
# pacman -Sy openssh procs
# .. start sshd
  • Client side
$ docker run -it --rm --entrypoint /bin/bash archlinux:latest
# ssh [server IP address]
# procs

@Saduff
Copy link

Saduff commented Jan 25, 2022

I tried the same way and could not reproduce it on my local machine, only on the remote server. On the server, the issue is there in the docker container as well when I run:

$ docker run --rm -it archlinux:latest
# pacman -Sy procs
# procs
^[]11;rgb:0000/0000/0000^[\ PID:▲ User │ TTY   CPU MEM CPU Time │ Command      
            │       [%] [%]          │              
 1     root │ pts/0 0.0 0.0 00:00:00 │ /usr/bin/bash
[root@a50d23103e27 /]# 11;rgb:0000/0000/0000

I found that the rgb string is printed to stderr, so I can suppress it like this and then everything is fine:

procs 2>/dev/null

What's weird is when I redirect it to a file, the file is empty:

# procs 2>test.txt
 PID:▲ User │ TTY   CPU MEM CPU Time │ Command      
            │       [%] [%]          │              
 1     root │ pts/0 0.0 0.0 00:00:00 │ /usr/bin/bash
# cat test.txt
# du test.txt
0 test.txt

I wish I had a way to reproduce it on my local machine, but I don't.

@dalance
Copy link
Owner

dalance commented Jan 25, 2022

What's weird is when I redirect it to a file, the file is empty:

The 11;rgb:0000/0000/0000 is a return value of background color query to terminal.
procs suppress the query if stdout/stderr is piped or redirected, so the redirected file becomes to be empty.

@Saduff
Copy link

Saduff commented Jan 25, 2022

Okay, it definitely has something to do with my terminal emulator. I tried lots of different terminal emulators:

  • Alacritty (TERM=alacritty) 🔴
  • cool-retro-term (TERM=xterm) ✔️
  • deepin-terminal (TERM=xterm-256color) ✔️
  • Konsole (TERM=xterm-256color) 🔴
  • kitty - my default (TERM=xterm-kitty) 🔴
  • Liri Terminal (TERM=xterm-256color) ✔️
  • QTerminal (TERM=xterm-256color) ✔️
  • Terminology (TERM=xterm) 🔴
  • urxvt (TERM=rxvt-unicode-256color) ✔️
  • xterm (TERM=xterm) 🔴
  • Xfce Terminal (TERM=xterm-256color) 🔴

✔️ denotes there's no issue (rgb string is not printed)
🔴 denotes that the rgb string is printed

None have the issue on my local machine, only when SSH'ed to the remote server.

@Saduff
Copy link

Saduff commented Jan 25, 2022

Okay, I found a way to reproduce it locally. It seems the issue has to do with network delay. The remote server is located far away so the latency is around 186 ms.

Steps to reproduce:

docker run --rm -it archlinux
# inside docker:
pacman -Sy openssh procs
ssh-keygen -A
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
passwd # change root password
/bin/sshd

Now, on docker host:

ssh root@172.17.0.2 # change container IP if necessary
procs # should be fine

Now, let's introduce a 200 ms network delay by running this on the docker host:

tc qdisc add dev docker0 root netem delay 200ms # run as root or with sudo
# verify that delay was added:
ping 172.17.0.2
  PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
  64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=200 ms

Now run procs in the other window again and the rgb string should be displayed. Since I found that it depends on the terminal emulator as well, pick one from above with the red dot. I used kitty personally.

Finally, to remove the delay:

tc qdisc delete dev docker0 root netem delay 200ms # run as root or with sudo

And when running procs again in the other window, it should be fine again.

@dalance
Copy link
Owner

dalance commented Jan 25, 2022

Thank you for your investigation.
procs waits 100ms until the query response.
So if there is 200ms network delay, procs will be timeout, after that the response will be displayed in the terminal.
But I can't increase the timeout because some terminals don't response the query.
I'll think another solution.

@dalance
Copy link
Owner

dalance commented Jan 25, 2022

Could you try 83305be ?

@Saduff
Copy link

Saduff commented Jan 25, 2022

Seems to be fixed with that. Thanks for the quick fix and for this awesome project. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants