C# 启动Nginx调试发现ErrorDataReceived被回调了两次,这是什么原因?

这是启动代码:

 ps = new Process();
 ps.StartInfo.FileName = exe;
 ps.StartInfo.Arguments = args;
 ps.StartInfo.UseShellExecute = false;
 ps.StartInfo.RedirectStandardOutput = true;
 ps.StartInfo.RedirectStandardError = true;
 ps.StartInfo.WorkingDirectory = workingDir;
 ps.StartInfo.CreateNoWindow = true;
 ps.EnableRaisingEvents = true;
 ps.ErrorDataReceived += Ps_ErrorDataReceived;
 
 ps.Start();

 ps.BeginOutputReadLine();
 ps.BeginErrorReadLine();
 if (wait) {
     ps.WaitForExit();
     ps.Close();
 }
 

Ps_ErrorDataReceived里我打印了e.Data,发现第一次是错误,第二次是个null,
这是什么原因呢?

阅读 2.9k
1 个回答

应该是输出了一个终结标志吧。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进