Getting live output from SteamCMD console C#

对着背影说爱祢 提交于 2019-12-11 02:44:48

问题


So the main problem is, that I can only get output programatically from SteamCmd when it terminates. The expected output would be:

Redirecting stderr to 'D:\User\Downloads\TF2Server\SteamCMD\logs\stderr.txt'
[  0%] ElAęrhetAĹ frissAştAęsek keresAęse...
[----] TelepAştAęs hitelesAştAęse...
Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam3...[HTTP Remote Control] HTTP server listening on port 27037.
OK.

Connecting anonymously to Steam Public...Logged in OK
Waiting for license info...OK
 Initial App state (0x4) installed
 App state (0x20104) validating, progress: 0.00 (0 / 5380081225)
 App state (0x20104) validating, progress: 0.99 (53119962 / 5380081225)
                               [...]
 App state (0x20104) validating, progress: 92.92 (4999198384 / 5380081225)
 App state (0x20104) validating, progress: 97.35 (5237711118 / 5380081225)
Success! App '232250' already up to date.

But it just redirect this text:

Steam Console Client (c) Valve Corporation
-- type 'quit' to exit --
Loading Steam3...OK.

Connecting anonymously to Steam Public...Logged in OK

Then when it terminates, coming the rest totally mixed:

 Waiting for license info...OK
 Initial App state (0x4) installed
 App state (0x20104) validating, progress: 0.02 (1048576 / 5380081225)
 App state (0x20104) validating, progress: 0.98 (52595346 / 5380081225)
                                  [...]
 App state (0x20104) validating, progress: 93.92 (5053012344 / 5380081225)
 App state (0x20104) validating, progress: 98.00 (5272580703 / 5380081225)
Success! App '232250' already up to date.
[HTTP Remote Control] HTTP server listening on port 27037.
Redirecting stderr to 'D:\User\Downloads\TF2Server\SteamCMD\logs\stderr.txt'
[  0%] Elérhető frissítések keresése...
[----] Telepítés hitelesítése...

So I googled for the solution a lot, then I found this issue: "https://github.com/ValveSoftware/Source-1-Games/issues/1684"

It says, that adding this to the code may solve the problem:

setvbuf(stdout, (char *)NULL, _IOLBF, 0);

How can I do this in c#?

This issue also refers to another (https://github.com/ValveSoftware/Source-1-Games/issues/352), saying:

When launching steamcmd.exe via the Windows CreateProcess() function, weird behavior occurs and steamcmd.exe spawns itself over and over.

Is there any way I can catch those processes and/or their outputs? Or any other ideas?

来源:https://stackoverflow.com/questions/25407924/getting-live-output-from-steamcmd-console-c-sharp

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