-
Notifications
You must be signed in to change notification settings - Fork 5k
Canceling the PosixSignal.SIGTSTP
does not seem to be handled correctly
#78302
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
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsDescriptionI am writing a console application in F# using .NET 7. I am wanting to intercept and prevent console exit signals, such as Reproduction StepsThese steps were executed on Ubuntu 20 running in WSL2 on Windows 11.
Expected behaviorWhen Actual behavior$ dotnet fsi posix.fsx
System is Linux
key: 'a', modifiers: 0
key: '\013', modifiers: 0
Prevented Posix SIGINT
key: 'a', modifiers: 0
[2]+ Stopped dotnet fsi posix.fsx
$ Prevented Posix SIGTSTP
key: 'a', modifiers: 0
$ Regression?Not sure. Known WorkaroundsNone that I know of. Configuration$ dotnet --version
7.0.100
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal The architecture is x64. Other informationNo response
|
The semantics of
We should look at the use-case and see what is the meaningful behavior when Looking at the code, I think they currently both do the same thing: prevent |
My understanding (and reason for bringing it up back then) is that the common use case for handling I can't really think of why one would want to completely block |
We can change it to do that, which is a breaking change, but probably the desired behavior. When at its default value of @bmitc how does that sound to you? |
I apologize for getting back to this so late. This is a side project that got pushed aside. Thank you @tmds and @alexrp for responding so quickly to this, and I'm again sorry for the delay. My use case was using pure F# to implement the modified Kilo text editor described in Build Your Own Text Editor. Specifically, it was in implementing the section Turn off
But to do this behavior in pure F#/.NET, I was needing the However, I am not remotely close to an expert on terminal implementations, which is one reason why I was working through this tutorial, so it's possible I misunderstand something here. |
Besides adding the Then you'll be able to read the Ctrl-C and Ctrl-Z combinations.
|
Moving this to .NET 9 as the likely fix is a breaking change and we're pretty late into .NET 8 for breaking changes. |
Sadly we didn't get to this in .NET 9 and it is likely still a breaking change, so moving to .NET 10. |
Description
I am writing a console application in F# using .NET 7. I am wanting to intercept and prevent console exit signals, such as
PosixSignal.SIGTSTP
andPosixSignal.SIGINT
. These enums are defined here. To ignore them, I create and register a handler usingPosixSignalRegistration.Create
and then writetrue
to theCancel
property inside the handler. This should cancel the signal, to my understanding, as it does forPosixSignal.SIGINT
. However, that doesn't seem to be the case forPosixSignal.SIGTSTP
.Reproduction Steps
These steps were executed on Ubuntu 20 running in WSL2 on Windows 11.
Save the following code into an F# script named
posix.fsx
.Run the script with
dotnet fsi posix.fsx
Type any character except
'q'
. The key information will be printed out.Enter
Ctrl + C
and note that"Prevented Posix SIGINT"
is printed out to the screen but that the process is still running, which can be verified by entering in other characters (again, besides'q'
).Enter
Ctrl + Z
and note that:[3]+ Stopped dotnet fsi posix.fsx
is printed to the screen"Prevented Posix SIGTSTP"
is printed out afterwards, after the new prompt is shown.Enter
is entered. This behavior is a little inconsistent.Expected behavior
When
Ctrl + Z
is entered,"Prevented Posix SIGTSTP"
should be printed to the console without the program being stopped.Actual behavior
Regression?
Not sure.
Known Workarounds
None that I know of.
Configuration
The architecture is x64.
Other information
No response
The text was updated successfully, but these errors were encountered: