-
Notifications
You must be signed in to change notification settings - Fork 254
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
fix: ensure proper cleanup of console process on shutdown #755
Conversation
16ab761
to
483e7c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also means we don't need the async PR either?
}); | ||
(this._ptyNative as IConptyNative).kill(this._pty, this._useConptyDll); | ||
}); | ||
(this._ptyNative as IConptyNative).kill(this._pty, this._useConptyDll); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this means we can remove conpty_console_list_agent.ts
and win/conpty_console_list.cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah left it as such incase you had use cases in future. Happy to remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove if we don't need
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I retain the old tree kill logic for useConpty
mode while useConptyDll
mode uses the new logic. This allows for a possible fallback incase things go horribly wrong. We can merge the two paths once we gain confidence.
Yeah it won't be needed with this change |
|
||
pty_baton(int _id, HANDLE _hIn, HANDLE _hOut, HPCON _hpc) : id(_id), hIn(_hIn), hOut(_hOut), hpc(_hpc) {}; | ||
}; | ||
|
||
static std::vector<pty_baton*> ptyHandles; | ||
static std::vector<std::unique_ptr<pty_baton>> ptyHandles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small cleanup to ensure proper lifetime management when the process exits.
@@ -107,6 +135,8 @@ void SetupExitCallback(Napi::Env env, Napi::Function cb, pty_baton* baton) { | |||
// so we only call CloseHandle for now. | |||
CloseHandle(baton->hIn); | |||
CloseHandle(baton->hOut); | |||
CloseHandle(baton->hShell); | |||
assert(remove_pty_baton(baton->id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were previously closing the client handle in pty.kill
which would invalidate waiting on the exit callback. Moved it closer to when the client has signaled exit.
Fix for microsoft/vscode#225719
Fixes #733
Based on etl profiles, we see that the OpenConsole processes are leaked since they are waiting on I/O from the pseudo client processes that are not terminated even when
pty.kill
command was issued.The changes associates all the client process to a job handle with
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
and the handle gets destroyed when the process hosting pty module gets torn down.