Skip to content

Clean up inconsistent code sending a Ctrl-C #4838

@egmontkob

Description

@egmontkob

Is there an existing issue for this?

  • I have searched the existing issues

Midnight Commander version and build configuration

git

Operating system

.

Is this issue reproducible using the latest version of Midnight Commander?

  • I confirm the issue is still reproducible with the latest version of Midnight Commander

How to reproduce

In src/subshell/common.c there are 3 places where we send Ctrl-C (write_all(..., "\003", 1)) to the subshell. Those three look all inconsistent. They should be made consistent and extracted to a helper method, if possible.

In all three of them, fish is handled as an exception, with no explanation. The explanation I believe is: fish doesn't repaint the prompt, and in turn doesn't reexecute its prompt command on a Ctrl-C, so we can't do a SIGCHLD-based synchronization to know when fish has finished handling this keypress.

https://github.com/MidnightCommander/mc/blob/4.8.33/src/subshell/common.c#L927

Even though with fish we don't send anything, we still set subshell_state = ACTIVE then.

Why don't we send Ctrl-C for fish if we do for other shells?

Also we call feed_subshell() recursively, pretty fishy [no pun intended].

https://github.com/MidnightCommander/mc/blob/4.8.33/src/subshell/common.c#L1402

We do send Ctrl-C to fish but don't process its response. This is okay-ish (we can't call feed_subshell() as that would wait for SIGCHLD which doesn't happen with fish), still, we'd need to read and discard fish's output, will that be done at some point later, and will the tty line surely not get clogged until then?

https://github.com/MidnightCommander/mc/blob/4.8.33/src/subshell/common.c#L1713

Here we again (like in the first case) don't send Ctrl-C to fish, but do we achieve whatever we achieve in other shells by that Ctrl-C?

Expected behavior

.

Actual behavior

.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues not related to a specific subsystemprio: mediumHas the potential to affect progress

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions