Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
We are using fastcgi-mono-server4 both in development and production. The application can easily be interrupted from the console by sending a SIGINT (Control-C) unless Console.SetForegroundColor is used, in which case the application continues to work correctly but can't be interrupted anymore.
This can easily be reproduced as follow:
1) In Xamarin Studio/MonoDevelop create a new Web Application (the one with default page).
2) Add the following code to the Default.aspx.cs file, at the end of the button1Clicked method:
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("This should print in nice cyan color!");
3) Go to the project directory and run:
MONO_OPTIONS=--debug fastcgi-mono-server4 /socket=tcp:127.0.0.1:9000 /applications=/:.
Control-C will correctly interrupt fastcgi-mono-server4.
4) Configure Apache or nginx to do FastCGI on localhost:9000 and load the root page a couple of times.
5) Now Control-C does nothing.
This is correct.
When you use any of the "enhanced" Console methods (colors, single-keystroke read, go-to column/location) we enable the advanced console, and that one takes over C-c.
By design I am afraid.
That's OK (probably should be documented somewhere). I have two questions though:
1) how is one supposed to intercept C-c after the advanced console has been enabled?
2) Is it possible to disable it (after using the "enhanced" methods?
You can use the Console's CancelKeyPress event.
There is no way to turn this off; your best bet is to avoid using any of the new Console APIs, and instead use something like curses, or roll your own.