Console.Error.WriteLine()写入stdout

时间:2017-08-27 06:34:53

标签: linux mono

以下计划:

MusicStoreDB

使用重定向的stderr运行时,仍会生成输出:

using System;

namespace teststderr {
    class MainClass {
        public static void Main(string[] args)
        {
            Console.Error.WriteLine("Hello World!");
        }
    }
}

根据strace,它确实写入fd 1.但如果我不重定向stderr,它会写入fd 2.我发现这种行为相当令人惊讶,并且无法在任何地方找到它。任何人都可以澄清它为什么会这样吗?

$ ~/test-stderr/test-stderr/bin/Debug/test-stderr.exe 2>/dev/null 
Hello World!

0 个答案:

没有答案