moonlight-stream / moonlight-embedded

Gamestream client for embedded systems
https://github.com/moonlight-stream/moonlight-embedded/wiki
GNU General Public License v3.0
1.48k stars 322 forks source link

Can't redirect stdout #865

Closed christovic closed 1 year ago

christovic commented 1 year ago

Please provide the following info.

NVidia Geforce Experience version: N/A Moonlight Embedded version: Moonlight Embedded 2.5.3-master-4c58ac9 Moonlight Embedded source: repository/included in distribution/compiled from source/... Compiled from source Moonlight Embedded running on: Raspberry Pi/Cubox-i/Hummingboard/Other linux device/... x86 Intel 12th Gen Moonlight Embedded running on distribution: Arch Linux/Raspbian/OpenELEC/... Debian

Strange one, I can't redirect stdout...?

Using bash, the command

moonlight stream -app Desktop -mapping gamecontrollerdb.txt.1 -1080 -fps 120 -bitrate 80000 -codec h265

will produce "Searching for server..." as output

but

moonlight stream -app Desktop -mapping gamecontrollerdb.txt.1 -1080 -fps 120 -bitrate 80000 -codec h265 > stdout.test

will create the file, but there'll be no output in it. There is no output in the terminal, so I know that it's definitely stdout.

I can't see anything special in the printf statements in main.c.

What is more curious, is that

moonlight > stdout.test

will write the stdout of the help text to the file.

Not a huge issue, but I'm struggling to figure this one out.

Also, moonlight map > stdout.test produces output in stdout.test.

christovic commented 1 year ago

Okay, so it does send it to stdout, but only once it quits. If I interrupt execution, it doesn't. I can't figure out why it wouldn't print to the file at the same time as it does to terminal though.

https://user-images.githubusercontent.com/41591830/221631282-750abf88-4e75-437b-9f9b-c0fee08aedc7.mp4

Hope the above video makes it clear what I'm talking about

cgutman commented 1 year ago

It's because stdout is line-buffered when writing to a TTY but fully-buffered when writing to a file.

There are a few utilities that can adjust the buffering method of stdout: https://stackoverflow.com/questions/11337041/force-line-buffering-of-stdout-in-a-pipeline

christovic commented 1 year ago

Amazing, thank you! I knew it would be something that went over my head.