uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.35k stars 1.24k forks source link

tail: after running tests, input is no longer shown in console #4956

Open cakebaker opened 1 year ago

cakebaker commented 1 year ago

After running the tail tests with

$ cargo test --features "tail" --no-default-features

the console no longer shows what I type (I'm using bash in KDE's Konsole).

tertsdiepraam commented 1 year ago

Can confirm that this is happening. Another strange thing happens too: when I hit ^C, it gives me 2 empty lines between prompts:

# before tail tests
[terts@deskspacex coreutils]$ ^C
[terts@deskspacex coreutils]$
# after tail tests
[terts@deskspacex coreutils]$ ^C

[terts@deskspacex coreutils]$

With fish, it all works fine. It also works fine with nextest in bash if you want a quick workaround.

Unrelated: These tests take a long time! I don't think we should have any tests that take longer than a second. nextest is reporting up to 12 seconds for some of them.

tertsdiepraam commented 1 year ago

This SO answer has a reasonable hypothesis: https://askubuntu.com/a/172747

After running the tail tests stty -a is indeed showing -echo.

tertsdiepraam commented 1 year ago

The offending commit based on git bisect seems to be: https://github.com/uutils/coreutils/commit/1725151ef827f07009c844bbda5ba6de7ab069d9

Update: the test that's causing this is test_follow_with_pid. It even has a comment describing that: " This test also breaks tty settings under bash requiring a 'stty sane' or reset."

Update 2: I have no idea why it does that but I don't have time to investigate further. I suggest we just turn that test off for now.

Absobel commented 11 months ago

It also works on zsh, it seems to be specifically bash

After some testing dummy.kill().unwrap(); is definitively the culprit. Killing sh manually with exit instead of sending SIGKILL works fine.

Tbf I don't know what the test does but maybe the kill method could be replaced by sending a more gentle signal. SIGTERM and SIGQUIT didn't work but somehow SIGUSR1 make sh quit gracefully and bash stty is normal after the test.

// This doesn't work :
// dummy.kill().unwrap();
// This does :
kill(Pid::from_raw(pid as i32), Signal::SIGUSR1).unwrap();
let _ = dummy.wait();

Edit : SIGHUP also works