hexyl icon indicating copy to clipboard operation
hexyl copied to clipboard

Interrupting hexyl with ^C leaves ugly remnant

Open vi opened this issue 6 years ago • 16 comments

screenshot

It should probably handle SIGINT and terminate the output as if it was EOF (but maybe with some mark):

│00001410│ 57 37 f9 ae 0b ae 6c 8a ┊ df 0e d8 20 15 f1 d7 f6 │W7×ו×l×┊×•× •×××│
│00001420│ a5 5e 99 b0 bd bf 22 a7 ┊ b2 e0 ab ^C             | ×^×××"×┊×××^C   |

vi avatar Jan 12 '19 11:01 vi

Thank you for reporting this. This should be easy to fix, yes.

sharkdp avatar Jan 13 '19 15:01 sharkdp

Fixed in v0.4.0.

sharkdp avatar Jan 14 '19 10:01 sharkdp

screenshot

Reproducible in multiple terminal emulators. Consistenly nice only in linux text terminal.

vi avatar Jan 14 '19 10:01 vi

This is what ctrl-c looks like on Mac OS X

Screenshot 2019-03-16 at 19 15 49

DannyCork avatar Mar 16 '19 19:03 DannyCork

If somebody has an idea how to fix this, let me know.

sharkdp avatar Apr 04 '19 19:04 sharkdp

Well, part of the problem is synchronous handling of ctrl+c. If you move process exit into the handler, the situation improves. I'm not sure what's actually safe to be called from a signal handler in Rust though (normally described in: man 7 signal-safety).

It's still a bit of a problem, I assume because of stdout buffering. May need some uglier tricks to work around (setbuf?).

domenpk avatar Jun 07 '19 14:06 domenpk

A possibly related issue is that on MacOS, when running hexyl without any input the application can't be terminated. Like this:

Screenshot 2020-02-07 at 08 24 53

This is with hexyl 0.6.0 on MacOS 10.14.6

secworks avatar Feb 07 '20 07:02 secworks

@secworks That looks like a different bug to me (much less esoteric than this one; thank you for reporting it). It would be great if you could create a new ticket.

sharkdp avatar Feb 10 '20 19:02 sharkdp

With the changes in #84, this is now open again. In my terminal and on zsh, this is not an issue. But apparently it causes problems in some terminal/shell combinations.

sharkdp avatar Mar 09 '20 20:03 sharkdp

@sharkdp Have you tried using alternative buffer when opening the application ? The smcup / rmcup capability of the terminal ?

sandorex avatar Jun 12 '20 11:06 sandorex

Using an alternative buffer would mean that you have to handle scrolling yourself and you can't see the output anymore after you exit hexyl.

bjorn3 avatar Jun 12 '20 16:06 bjorn3

I guess the only other thing i can think of is disabling echo and reenabling it after quitting, but you probably already did that right?

sandorex avatar Jun 12 '20 20:06 sandorex

I'm not sure what that means?

sharkdp avatar Jun 17 '20 16:06 sharkdp

echo is when you press a key it displays on the terminal, but i think it is already disabled otherwise any key would be visible on a press

sandorex avatar Jun 17 '20 18:06 sandorex

Echo is enabled. I can still type stuff while I run cat /dev/zero | pv -q -L 16 | hexyl (read zeros at a rate of 16 bytes per second)

bjorn3 avatar Jun 17 '20 19:06 bjorn3

@bjorn3 You are right

I've been able to test it with little bash (does not work on zsh)

orig=$(stty -g)
stty -echo
hexyl /dev/urandom
stty $orig

And it doesnt show the ^C anymore

sandorex avatar Jun 18 '20 13:06 sandorex

I'm closing this due to inactivity. And because I can not reproduce this on my machine. Please feel free to comment in case it should be re-opened.

sharkdp avatar Dec 05 '22 20:12 sharkdp