leo-arch / clifm

The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell.
https://github.com/leo-arch/clifm/wiki
GNU General Public License v2.0
1.33k stars 40 forks source link

Returning to `clifm` prompt after suspending a running job by sending the suspend character (`Ctrl+Z`) #275

Open whatbh opened 6 months ago

whatbh commented 6 months ago

Describe the bug In a shell, sending the suspend character (Ctrl+Z) will suspend the currently running job and return to the shell prompt. In clifm, pressing Ctrl+Z will not return to clifm prompt but put it into an unusable state.

To Reproduce Steps to reproduce the behavior:

  1. In clifm, run a program in foreground (top, ping, glxgears, nautilus, whatever...)
  2. Press Ctrl+Z (to send suspend character) to suspend it.

Expected behavior Suspend the program and return to the clifm prompt.

Screenshots Screenshot 2024-03-28 160435

Desktop (please complete the following information):

leo-arch commented 6 months ago

Hi @whatbh.

Ctrl-z for external commands was disabled in https://github.com/leo-arch/clifm/commit/8325919ec88c602e75357dfa20f1ea5f034233c5. Of course this is not a solution, but at least it won't let the shell in an unusable state anymore.

fidodido48 commented 1 week ago

The bug is still present in v. 1.20 on Arch. Hangs whole clifm and no way to get back control of it. Is this gonna be fixed?

leo-arch commented 1 week ago

Hi @fidodido48. What command are you running exactly? It seems to happen only with specific commands. For example, it does happen with top, but not with ping, glxgears, or htop.

fidodido48 commented 1 week ago

Hello. Ive tried to suspend rsync for a while.

<0> $ rsync-move 3 6 ~/DLDIR/YTV/SC2/
sending incremental file list
NA.ESL SC2 Masters - B stream: Winter 2023 Regionals Day 6 - Swiss Round 3.mp4
          5,97G 100%    8,05MB/s    0:11:47 (xfr#1, to-chk=1/2)
NA.ESL SC2 Masters: Summer 2023 Finals Day 1 - Winners Stage - Stream B.mp4
         10,10G 100%    3,14MB/s    0:51:10 (xfr#2, to-chk=0/2)
^Z

And it just hangs like that.

leo-arch commented 1 week ago

Suspend is disabled because clifm does not do job control. Are you sure it is hanged? Try with Control-C to kill the program and see whether it is responsive or not.

fidodido48 commented 1 week ago

Its not responding - just prints '^C'. Have to kill clifm process from other terminal. This leaves a rsync-zombie process.

leo-arch commented 1 week ago

Ok. I'll keep investigating this issue. I'm not sure why this happens with some programs and not with others.

This is what we know thus far: Ctrl-z is definitely disabled, but some programs (rsync, top) do not like it and do not even allow you to kill the process via a signal (Ctrl-c), while others (ping, xlgears, htop) behave as expected: Ctrl-z is ignored and they just continue running.

I also observed that this depends at some point on the underlying shell. For example, if you run clifm using zsh (CLIFM_SHELL=/bin/zsh clifm), ping misbehaves just as top, while this does not happen if you use bash, dash, or ksh.

fidodido48 commented 6 days ago

If anyone needs it - from other terminal: pkill -CONT <suspended_process_name> Worked on ping and top.

leo-arch commented 6 days ago

I've found out that the issue can be reproduced independently of clifm. For example:

exec sh -cm top

where -m means: SIGTTIN, SIGTTOU, and SIGTSTP signals shall be ignored (from the sh manpage).

Again, since this doesn't happen with htop, among others, I assume that the issue is related to how the exec'd program behaves when SIGTSTOP (Ctrl-z) is ignored, and not (or at least not directly) to clifm itself.