[Mono-bugs] [Bug 74190][Wis] Changed - Console.WriteLine gives UnauthorizedAccessException

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 3 Apr 2005 10:09:53 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by tauberer@for.net.

http://bugzilla.ximian.com/show_bug.cgi?id=74190

--- shadow/74190	2005-03-30 22:11:14.000000000 -0500
+++ shadow/74190.tmp.8862	2005-04-03 10:09:53.000000000 -0400
@@ -68,6 +68,31 @@
 
 ------- Additional Comments From tauberer@for.net  2005-03-30 22:11 -------
 Yeah, I tried reproducing it by closing fd 0 with Mono.Unix.Syscall,
 and I managed to bring out another exception by closing it before the
 System.Console type initializer runs.  But I couldn't reproduce the
 exception above... yet.
+
+------- Additional Comments From tauberer@for.net  2005-04-03 10:09 -------
+I figured out how to generate the exception.  The code below uses dup2
+to replace standard out with a file opened read-only.
+
+As for reproducing it in mod-mono, you might need to apply my control
+panel patch and use that to restart mod-mono-server a few times.  I'm
+not sure.
+
+But maybe the appropriate thing to do is modify the class lib to
+ignore problems writing to the console?
+
+using System;
+using Mono.Unix;
+
+public class Test {
+
+        public static void Main() {
+                int fd = Syscall.open("/tmp/test",
+OpenFlags.O_RDONLY|OpenFlags.O_CREAT);
+                Syscall.dup2(fd, 1);
+                Console.WriteLine("Testing.");
+        }
+}
+