Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add using_terminal stanza #3660

Closed
wants to merge 13 commits into from
Closed

Add using_terminal stanza #3660

wants to merge 13 commits into from

Conversation

CT075
Copy link
Contributor

@CT075 CT075 commented Jul 30, 2020

As per #3464 .

Todo:

  • Capture standard terminal output while the terminal lock is held
  • Add tests

@CT075 CT075 marked this pull request as draft July 30, 2020 03:21
@ghost
Copy link

ghost commented Jul 30, 2020

That looks right to me, but we also need to prevent dune from printing messages while such an action is running. This should be done globally via the Console module in src/stdune/console.mli.

@CT075
Copy link
Contributor Author

CT075 commented Sep 3, 2020

That looks right to me, but we also need to prevent dune from printing messages while such an action is running. This should be done globally via the Console module in src/stdune/console.mli.

I'm unsure of what the behavior in this case should be. Should we silently eat anything sent to the console during such an action, or capture them to be output later?

@rgrinberg
Copy link
Member

Should we silently eat anything sent to the console during such an action, or capture them to be output later?

The latter seems much more reasonable to me.

@rgrinberg
Copy link
Member

Quoting Jeremie from the original issue:

Only one such action can run at a time, and while such an action is running messages emitted by dune would be put in a queue and rendered once the action has finished.

@rgrinberg
Copy link
Member

Adjust dune/context.ml to possibly take into account the selective terminal usage?

What needs to be adjust in context.ml?

@CT075
Copy link
Contributor Author

CT075 commented Sep 8, 2020

Adjust dune/context.ml to possibly take into account the selective terminal usage?

What needs to be adjust in context.ml?

This was an idea I had when I was far less familiar with how the codebase functioned; I'm no longer sure what I really meant. I'll remove it from the PR description.

@CT075 CT075 requested a review from rgrinberg September 10, 2020 16:07
@CT075
Copy link
Contributor Author

CT075 commented Sep 10, 2020

I'd really like to make Console.lock and Console.unlock idempotent (or, even better, expose only a safe interface for buffering, but I suspect that this would require pulling in Fiber), but I'm not really sure how a buffered console should interact with console composition (for that matter, I'm not sure that it currently does that correctly, either).

@CT075
Copy link
Contributor Author

CT075 commented Sep 10, 2020

Wait, for that matter, what is terminal composition currently useful for? Neither grepping over the codebase or using github search seems to come up with any uses of it.

@CT075 CT075 marked this pull request as ready for review September 10, 2020 18:27
@CT075 CT075 changed the title [WIP] Add using_terminal stanza Add using_terminal stanza Sep 11, 2020
; stderr_to = Process.Io.stderr
}
in
Console.unlock ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the exec above raises? Shouldn't we still unlock?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed.

To allow these to be used alongside [Fiber] jobs, we expose this unsafe
interface instead of [with_lock: (unit -> unit) -> unit]. Double-[lock]ing
or [unlock]ing the console will lead to output errors (no output, repeated
output, etc). *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just forbid double locking/unlocking via runtime checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spoke to @jeremiedimino about the behavior of terminal locking in the presence of composed terminals, and we concluded that we don't need to worry about it for now, so I've adjusted the interface.

@ocaml ocaml deleted a comment from cwong-ocaml Sep 16, 2020
@ocaml ocaml deleted a comment from cwong-ocaml Sep 16, 2020
Base automatically changed from master to main January 14, 2021 17:08
@rgrinberg rgrinberg marked this pull request as draft February 28, 2023 18:30
@rgrinberg
Copy link
Member

Please re-open if this is still relevant

@rgrinberg rgrinberg closed this Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants