Skip to content

Don't test the persistent command feature #4935

@egmontkob

Description

@egmontkob

Is there an existing request for this?

  • I have searched the existing issues

Is your feature request related to a problem?

Upon startup, mc tests whether the shell supports reporting the pending command line, i.e. our prerequisite for our persistent command line feature.

This resulted in race conditions, some of which were eliminated e.g. as part of #4625 / PR #4934, but due to a Solaris kernel bug #4812 still remains and we don't know how to fix that.

Strictly speaking, these race conditions were/are still there during normal operation of mc, but are many magnitudes less likely to surface because then, unlike at startup, an interactive user action is involved.

At #4625 (comment) it was suggested that we don't need to test for this feature, we can (in some circumstances) be sure that it works.

In turn, at #4625 (comment) it was pointed out that it wouldn't work. But now that I think about it, this was an oversight, this comment was incorrect. The outer terminal, and anything between the outer terminal and mc (e.g. possibly an ssh) isn't involved in this game. It all happens in the inner terminal, i.e. between mc as the tty master and the subshell as the pty slave.

If we know that the shell is new enough to support this feature, there's no need to test it. Now, very slightly maybe, under some extremely heavy and unusual user setups, maybe there's a chance that it won't work, but under such extremely weird setups many of our other solutions (e.g. the sigstop-sigcont dance, or writing to the subshell pipe) could also fail. And, worst case, we'd just hit the timeout then and disable the feature for the rest of the session.

We'd need to know whether the subshell is new enough to support the said feature. There are several ways to do that. We could run the shell with --version first and parse its output. We could construct our shell initialization code in init_subshell_precmd() to report its version via a pipe. Or, if all versions of the shell support the necessary bindkey, but may not yet support querying the command line buffer, then mc could recognize the empty command line and empty (rather than 0) cursor position in the response, with no upfront version reporting whatsoever (actually, in case of bash, we also explicitly report the version).

This approach could allow some code cleanup (e.g. hopefully the removal of the newly introduced gboolean subshell_initialized), some design uniformization (we don't test other features either, we have a timeout just in case they break whenever we use on them), and would work around the aforementioned Solaris bug of #4812.

Describe the solution you'd like

.

Describe alternatives you've considered

No response

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

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions