~sircmpwn/gmni#65: 
gmnisrv: set stdout to line buffer

When using gmnisrv with systemd-journald, I noticed that log lines are not output immediately. This is because (as far as I understand) when stdout is redirected to a file, the output is buffered; that prevents being able to see the log output using journalctl in real time.

The temporary solution to this is using something like unbuffer or stdbuf --output=L gmnisrv.

The permanent solution would be to set stdout to be line buffered in the program. That can be done using the setvbuf or setlinebuf call. More information can be found in man 3 setlinebuf.

I would submit a patch adding the following to main.c, but I'm not sure what the right location would be. AFAICT, anytime before it starts logging should work.

setvbuf(stdout, NULL, _IOLBF, 0);
Status
REPORTED
Submitter
Karmanyaah Malhotra
Assigned to
No-one
Submitted
a month ago
Updated
a month ago
Labels
No labels applied.