Skip to content

Commit

Permalink
Fix lack of stdout line buffering
Browse files Browse the repository at this point in the history
  • Loading branch information
c4rlo committed Dec 8, 2024
1 parent f5e9d64 commit f9f3af5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cerrno>
#include <concepts>
#include <cstddef>
#include <cstdio>
#include <iostream>
#include <print>
#include <regex>
Expand Down Expand Up @@ -112,6 +113,11 @@ struct FdGuard {

int main()
{
if (std::setvbuf(stdout, nullptr, _IOLBF, BUFSIZ) != 0) {
reportError("set stdout line buffering", errno);
return 1;
}

const int kmsgFd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK | O_CLOEXEC);
if (kmsgFd == -1) {
reportError("open /dev/kmsg", errno);
Expand Down

0 comments on commit f9f3af5

Please sign in to comment.