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

Clean up and pop dead runspace when using 'attach' #896

Merged

Conversation

TylerLeonhardt
Copy link
Member

Previously, when you used the attach launch config, if you killed the process that you were attaching to while PSES was attached to it, PSES would go into a bad state and hang forever.

This was because the Runspace wasn't getting cleaned up properly when the connection between the two processes broke.

This change checks for the bad runspace state, cleans up, and pops the bad runspace.

Here's what you see:

[DBG]: [Process:42420]: [Runspace1]: PS /Users/tyler/Downloads/anothertestfunc>> 

Command or script completed.
To end the debugging session type the 'Detach' command at the debugger prompt, or type 'Ctrl+C' otherwise.

Leaving debugged runspace on local machine Tylers-MacBook-Pro
The background process reported an error with the following message: "The named pipe target process has ended.".
At line:0 char:0
PS /Users/tyler/Downloads/anothertestfunc>

which is very consistent with what pwsh.exe shows when this happens.

// process you're attached to dies randomly.
if (this.CurrentRunspace.Runspace.RunspaceAvailability == RunspaceAvailability.None)
{
this.AbortExecution();
Copy link
Collaborator

Choose a reason for hiding this comment

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

👀 aha!

@TylerLeonhardt
Copy link
Member Author

I definitely want @SeeminglyScience's green check on this

Copy link
Collaborator

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

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

LGTM but I don't know the "attach" part of the debugger code all that well.

Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

LGTM!

@TylerLeonhardt TylerLeonhardt merged commit 721745f into PowerShell:legacy/1.x Mar 29, 2019
@TylerLeonhardt TylerLeonhardt deleted the fix-attach-hang branch March 29, 2019 02:23
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.

None yet

4 participants