Prevent mcedit from hanging on macro#5070
Prevent mcedit from hanging on macro#5070jtyr wants to merge 1 commit intoMidnightCommander:masterfrom
Conversation
|
Please add a detailed info to the commit message. |
|
Just to be sure what looks like an oversight to me here is only due to my own lack of understanding: Does that "subshell" refer to the visible prompt line that's by default shown below the panels in plain |
|
it's the same subshell, just presented differently. the comments in the surrounding code imply this pretty strongly, so i guess you didn't look very hard. with some minor adjustments (omitting the "meta" stuff), the PR description would make a fine commit message. there should be a code comment explaining the conditional concisely, like the other ones. @egmontkob was poking this code most recently, so he may have a more profound opinion. |
Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com>
Summary
Fixes editor hang when executing macro scripts via
mc -e.Problem
Running MC in editor-only mode (
mc -e file) and executing a macro script (e.g., viaedit_block_process_cmd) causes the editor to hang indefinitely.The hang occurs in
invoke_subshell()insrc/subshell/common.c. Before sending a command to the subshell, the code sends Ctrl-C to clear any leftover input and callsfeed_subshell(QUIETLY, FALSE)to wait for the shell to reach a prompt. This wait relies on the shell's prompt hook writing its CWD to a pipe - but in editor-only mode (MC_RUN_EDITOR),use_persistent_bufferisFALSEand the shell's CWD-reporting hook is not active, sofeed_subshellblocks forever onselect().Fix
Skip the Ctrl-C +
feed_subshellpre-clearing when not in full MC mode. This code path exists to clear user-typed text from the subshell prompt before injecting a command - but in editor mode, the subshell has not been interacted with by the user, so there is nothing to clear.Test plan
mc -e somefile- select a text block, run a macro script - should execute without hangingmc, edit a file (F4) and run a macro script - should work as before