Why does redirecting StandardOutput of GAWK always prepend fstat

不羁的心 提交于 2021-01-28 06:50:38

问题


I have following code to read and redict the output of gawk to a textfile (instead of doing this with shell-execute and using >):

var processStartInfo = new ProcessStartInfo
                       {
                         FileName = "gawk.exe",
                         Arguments = $@"-F ""{separator}"" -f ""{scriptFullFileName}"" ""{inputFullFileName}""",
                         UseShellExecute = false,
                         WorkingDirectory = workingDirectory,
                         RedirectStandardOutput = true,
                         CreateNoWindow = true
                       };
using (var process = Process.Start(processStartInfo))
{
  using (var streamReader = process.StandardOutput)
  {
    var result = streamReader.ReadToEnd();
  }
}

Inspecting result afterwards, it always starts with the following lines:

fstat < 0: fd = 0
fstat < 0: fd = 2

Whereas executing gawk.exe from the shell, these lines are not present.

What am I doing wrong - or better, how can I get rid of these 2 lines without additional parsing?


回答1:


This very issue is connected to the used version of gawk.exe, which was 3.1.6.2962. With 4.1.3 this problem does not occur.



来源:https://stackoverflow.com/questions/35067123/why-does-redirecting-standardoutput-of-gawk-always-prepend-fstat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!