-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Expose more information about the state of the integrated terminal internally within vscode and to the API #11422
Comments
Specifically I'd like to request that the PID of the terminal be available on the Terminal object. Some of the coordination I do in the PowerShell extension relies on having the PID of the PowerShell process so that my debug adapter knows where it should look for connection details when a debugging session is started. |
@daviwil what sort of things are you going to use the PID for? Wondering if we can provide more high level APIs then just the PID to prevent some boilerplate in many extensions. |
That's a good question, and typing out my reasoning just now reminded me that I don't actually use the PowerShell PID for anything other than just logging purposes (and knowing which process to attach a debugger to when things go south). I guess it isn't super critical for me to have the PID but it's definitely helpful for debugging purposes. |
It is now still on
It would be nice if availability of PID could be preserved at least before that moment. |
@whitecolor as I mentioned in #10546 (comment), |
Forked exposing PID to #11919 which I hope to get in for September. |
From @isidorn in #13351 (comment)
@weinand and I have spoken about it before. It's a little more tricky that just saying that some text passed to One idea is to track when child processes of the pty process are spawned and die and report that, not sure how difficult/reliable that is though, it would probably also be best done upstream. Another is to ask the terminal whether it has a particular child process after the command has started, but this still has the reliability issues mentioned earlier. |
This is done by pattern matching. If you define a watch tasks you can provide patterns for the inactive->active transition and active->inactive transition. |
I wonder if checking creating some events in xterm.js that trigger when the cursor visibility toggles might be a better way of getting whether the shell is busy. I think there are issues on Windows with the cursor displaying sometimes when it shouldn't but if that was fixed it might be a reasonable way of doing this? |
Other ideas:
|
Pretending I didn't mention already the concept of co-processes in iterm. See https://iterm2.com/documentation-coprocesses.html and #13337 |
@jrieken co-processes wouldn't allow an extension to determine if a process is currently running the shell though, only reacting to stdout. While you could potentially scan stdout for a pattern to know if the command has terminated, if there's a way to solve this in a more generic way that was guaranteed to work would be very useful and convenient. Something like this: Terminal.isAcceptingInput(): boolean;
// isBusy, canInput, isProcessRunning, etc.
enum TerminalState {
BUSY,
NOT_BUSY
}
Terminal.onStateChange(): Event<TerminalState>; The main use case for this I've seen so far is knowing when a command is finished so an extension knows what state a terminal is in and can react accordingly (reuse terminal, close and open new, open new). |
I see |
What would be helpful as well if I could start a terminal and execute exactly one command and then terminate the terminal as well. |
@dbaeumer is the reason for using the terminal over an output channel its support for colors? I've thought about the idea of making an integrated terminal instance read only to prevent unwanted interaction (which would probably be wanted for this). |
It is color support. But I have also the request that a task should allow user input. |
Created #15584 based on our discussion. |
Closing in favor of #20676 |
Originally discussed in #9957 and then in #11214, consumers of the API want to know more about the process(es) currently being run within the terminal, such as what process(es) are running and whether the terminal is "busy".
The text was updated successfully, but these errors were encountered: