Skip to content

Prevent mcedit from hanging on macro#5070

Open
jtyr wants to merge 1 commit intoMidnightCommander:masterfrom
jtyr:jtyr-mcedit-hang
Open

Prevent mcedit from hanging on macro#5070
jtyr wants to merge 1 commit intoMidnightCommander:masterfrom
jtyr:jtyr-mcedit-hang

Conversation

@jtyr
Copy link

@jtyr jtyr commented Mar 15, 2026

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., via edit_block_process_cmd) causes the editor to hang indefinitely.

The hang occurs in invoke_subshell() in src/subshell/common.c. Before sending a command to the subshell, the code sends Ctrl-C to clear any leftover input and calls feed_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_buffer is FALSE and the shell's CWD-reporting hook is not active, so feed_subshell blocks forever on select().

Fix

Skip the Ctrl-C + feed_subshell pre-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 hanging
  • Full MC mode - run mc, edit a file (F4) and run a macro script - should work as before

Signed-off-by: Jiri Tyr <jiri.tyr@gmail.com>
@github-actions github-actions bot added needs triage Needs triage by maintainers prio: medium Has the potential to affect progress labels Mar 15, 2026
@github-actions github-actions bot added this to the Future Releases milestone Mar 15, 2026
@mc-worker
Copy link
Contributor

Please add a detailed info to the commit message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs triage Needs triage by maintainers prio: medium Has the potential to affect progress

Development

Successfully merging this pull request may close these issues.

2 participants