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

Resizing Wait-Event crashes PowerShell on macOS #16174

Closed
5 tasks done
yumaikas opened this issue Sep 30, 2021 · 16 comments
Closed
5 tasks done

Resizing Wait-Event crashes PowerShell on macOS #16174

yumaikas opened this issue Sep 30, 2021 · 16 comments
Assignees
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a OS-macOS Resolution-Answered The question is answered. WG-Interactive-Console the console experience

Comments

@yumaikas
Copy link

yumaikas commented Sep 30, 2021

Prerequisites

Steps to reproduce

  1. Be on macOS Big Sur, Version 11.6

  2. Launch a PowerShell session in Terminal.

  3. Run Wait-Event, then stop it via Ctrl-C

  4. Run. Wait-Event again, but resize the terminal.

Expected behavior

PowerShell doesn't exit

Actual behavior

Powershell exits on terminal resize. 

If the terminal is hosted inside Neovim, it shows shows "Process exited 130", 

If the terminal is only hosted inside of the macOS Terminal.app shows "[Process completed]"

Error details

(Nothing)

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.4
PSEdition                      Core
GitCommitId                    7.1.4
OS                             Darwin 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@yumaikas yumaikas added the Needs-Triage The issue is new and needs to be triaged by a work group. label Sep 30, 2021
@yumaikas
Copy link
Author

Of note, this issue gives me a lot of grief when I run long-running foreground commands in PowerShell in Neovim, like a custom file polling script I have.

The above reproduces outside of that context.

@iSazonov iSazonov added Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a OS-macOS WG-Interactive-Console the console experience labels Sep 30, 2021
@yumaikas
Copy link
Author

yumaikas commented Oct 1, 2021

Why does this have Issue-Question instead of Issue-Bug?

@iSazonov
Copy link
Collaborator

iSazonov commented Oct 2, 2021

Why does this have Issue-Question instead of Issue-Bug?

Work Group will do a conclusion.

Please update your repro steps (it is not clear about Neovim).

@yumaikas
Copy link
Author

yumaikas commented Oct 5, 2021

The repro steps are updated. Is there anything further I should do to help the WG be able to attack this? I can attempt to run PowerShell Core inside a debugger, and reproduce it there, though that will take some time.

@yumaikas
Copy link
Author

yumaikas commented Oct 5, 2021

So, I found out something curious about my setup that suggests this isn't a PowerShell specific bug:

I'd set up a pwsh.nologo script to act as my interactive shell with the following

#! /bin/zsh
/usr/local/bin pwsh -Login -nologo

I noticed that running this outside of a logo environment, didn't seem to run into the same error.

Switching it to:

#! /usr/local/bin/pwsh
/usr/local/bin/pwsh -Login -nologo

Seems to get rid of this bug. Unless you want something else from me, I'll close this issue in 48 hours.

@iSazonov
Copy link
Collaborator

iSazonov commented Oct 6, 2021

I don't think we support zsh. /cc @rjmholt

@rjmholt
Copy link
Collaborator

rjmholt commented Oct 6, 2021

Things should work running underneath another shell. I do that a lot on Linux myself.

However, for this issue it'd be nice to rule out this being caused by zsh interfering in some way.

I will say, I'm not sure why you'd want a login script to be a PowerShell script (with the pwsh shebang) that then calls PowerShell with arguments -- that means you're starting two PowerShell processes, one within another.

I'm fairly sure you can specify arguments in a shebang, but also I think you can give them in your login shell configuration (maybe in /etc/shells?).

@yumaikas
Copy link
Author

yumaikas commented Oct 6, 2021

So, the reason I do this is because I want to able to set -Login and -nologo, and I'm totally unaware of any non-CLI flag options for doing so. I tried setting flags via /etc/shells, and that didn't work for me. So, I've created a script that just calls PowerShell, like I showed above.

Do you want me to try a different shell for my shebang line? Do environment variables exist that I could use to drive -Login/-nologo?

I've documented what I'm doing here: https://junglecoder.com/blog/pwsh-osx-nologo

@yumaikas
Copy link
Author

yumaikas commented Oct 6, 2021

I did do a decent amount of digging around trying to piece together how I got here, but this depth of customizing login shells is new territory for me, so there is a chance that I've missed something.

That being said, /bin/dash and /bin/sh both seem to not crash due to resizes, as well as /bin/pwsh, so it does look more related to zsh than pwsh.

@rjmholt
Copy link
Collaborator

rjmholt commented Oct 7, 2021

You could try /bin/sh with the login flag -- other than zsh I don't think there's much else for default shells on macOS (I'm pretty sure bash will be taken out soon). The only thing I'd avoid is using pwsh in the shebang to start pwsh, since two pwsh startups is a lot of overhead and will be slow.

Depending on what terminal you use, you should also be able to configure the default shell invocation (certainly iTerm2 allows that).

@yumaikas
Copy link
Author

yumaikas commented Oct 7, 2021

So, it turns out that I can use exec like so:

#! /bin/zsh
exec /usr/local/bin pwsh -Login -nologo

And that works around it. I got that tip from Bart Schaefer on the zsh-workers mailing list.

Funnily enough, I think I notice more startup time using zsh than I do with nested pwsh calls.

I use kitty and/or Terminal.app atm.

@yumaikas
Copy link
Author

yumaikas commented Oct 7, 2021

From what I could tell with dtruss, the nested pwsh session seems to send a QUIT signal (or something of the like) that the zsh session isn't monitoring for.

I have ways to work around it, so it's not a critical issue at this point, more of a quirk.

For me, /etc/shells shows quite a few options:

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/pwsh
/usr/local/bin/pwsh.nologo

@theJasonHelmick theJasonHelmick self-assigned this Jun 6, 2022
@theJasonHelmick theJasonHelmick removed the Needs-Triage The issue is new and needs to be triaged by a work group. label Jun 6, 2022
@theJasonHelmick
Copy link
Collaborator

@yumaikas - Thanks for the issue - I haven't been able to reproduce this error using PowerShell 7.2.2 on MacOS using terminal or iTerm2. Can you confirm?

@theJasonHelmick theJasonHelmick added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Jun 6, 2022
@yumaikas
Copy link
Author

I wasn't able to reproduce it locally running pwsh from Zsh, so I think this is now working better.

@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Jun 13, 2022
@theJasonHelmick
Copy link
Collaborator

@yumaikas - thank you for the response -- It is possible that an upgrade to .NET may have fixed this. We tried to repo on PowerShell 7.2.x and 7.3 -- the error did not reproduce.

@theJasonHelmick theJasonHelmick added the Resolution-Answered The question is answered. label Aug 17, 2022
@ghost
Copy link

ghost commented Aug 19, 2022

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

@ghost ghost closed this as completed Aug 19, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a OS-macOS Resolution-Answered The question is answered. WG-Interactive-Console the console experience
Projects
None yet
Development

No branches or pull requests

4 participants