I am interested in knowing if we can catch SIGINT, SIGHUP equivalent signals in Powershell and how to do it?
I also could not find if there is anything equivalent in powershell like "stty -echo" in unix environment.
Thanks,
I am interested in knowing if we can catch SIGINT, SIGHUP equivalent signals in Powershell and how to do it?
I also could not find if there is anything equivalent in powershell like "stty -echo" in unix environment.
Thanks,
I don't think Windows has functionality equivalent to Unix signals in general. The API functions GenerateConsoleCtrlEvent and SetConsoleControlHandler are about as close as you're likely to get, but I don't know if they're exposed in any way by Powershell. I think you're completely out of luck if you need a Windows equivalent to some of the more esoteric Unix signals like SIGHUP.
Edit: I see from one of the answers to your previous question that Powershell
does have a trap
command -- but it seems to handle .Net exceptions, which
I wouldn't consider equivalent to Unix signals.
About an equivalent for stty -echo
-- sorry, no idea.
I haven't used terminals much, but after some searching to try to understand the significance of stty -echo
I think you may be able to get a similar effect by creating a helper to PInvoke SetConsoleMode.
As for SIGINT (if I understand it right), I think there are interruption exceptions in .NET and PowerShell. But that may only be for threads and pipelines.