-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Terminal confirmOnExit should only warn when the terminal shell is running something #23808
Comments
Are you working on this or could a new contributor take a stab at it? I use the integrated terminal almost always, and I think this is something I could take a crack at. |
@Njanderson wasn't planning on working on it for a while, it would be fantastic if you could give it a go 😃. The plan was basically to investigate the best/most reliable methods to count the number of child processes of a PID on each OS and implement each of them. |
For Windows, I was thinking of doing something like:
I also see that this test shows that we have the process id of the terminal, so I have a bit more confidence. 👍
With the process id, I could use powershell or windows to call wmic. Then, for me, winpty-agent.exe is the parent of that pid for cmd or powershell. For Ubuntu and Mac, what you said seems to work for me.
These seem like potential solutions, but I am not sure how to proceed with executing these commands, even if I know where to add them. As for where these commands are executed, in terminalService.ts:
As for how, do we try to use another terminal session? Where would you like the platform specific code to be run? |
Thanks for looking into this @Njanderson, sorry about not getting to this I took last week off and am still catching up. Your proposal looks pretty good, just keep Note that on Windows processId won't be correct until #14286 is resolved where I need to release and update an npm dep. We also need to confirm that |
This fix sees the method of checking sub-processes in debug world for all platforms #37589 (comment) 8f36137 The terminal should have something similar to this. |
We may want to add a "running" icon as part of capturing this state? #59672 |
Any update here? |
No update, open to PRs though. Basic outline of what needs to happen is to put logic to query the process probably inside terminalProcess.ts, and then call into it like TerminalInstance -> TerminalProcessManager -> TerminalProcess. |
When this change is made I would like to also have a setting that reverts to the current behavior, i.e. warn on exit even if there are no subprocesses. |
@NotWearingPants noted, we'd probably want to change confirmOnExit to a string enum then: |
This is an issue that I have struggled with as well, I can take it up. 🤘 |
@lambainsaan sounds good, some more info:
|
🎉 |
Tested on Windows (running |
We could check if the shell process from node-pty has any child processes using something like
pgrep -P <pid>
. If we do this confirmOnExit=true may be better off as the default.The text was updated successfully, but these errors were encountered: