From 049075af2de33fa5207410bd9de656a86bdb1580 Mon Sep 17 00:00:00 2001 From: gaulthier gain Date: Tue, 3 Mar 2020 10:23:24 +0000 Subject: [PATCH] Update __stdout_write to allow flushing on stdout This patch fixes the issue where printing on stdout does nothing since stdout was not flushed. In that case, we found that the problem was related to __stdout_write. Indeed f->lbf must be set to '\n' for line-buffered mode nevertheless, the condition "(!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz))" fails on Unikraft. The variable f->lbf is thus reset to -1 which prevents a correct display on stdout. With this patch, we "force" f->lbf to be set in line-buffered mode. Signed-off-by: gaulthier gain Reviewed-by: Simon Kuenzer --- ...09-update__stdout_write_for_flushing.patch | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 patches/0009-update__stdout_write_for_flushing.patch diff --git a/patches/0009-update__stdout_write_for_flushing.patch b/patches/0009-update__stdout_write_for_flushing.patch new file mode 100644 index 0000000..bda423f --- /dev/null +++ b/patches/0009-update__stdout_write_for_flushing.patch @@ -0,0 +1,25 @@ +From 235b3d8240fbc99782f2fb8449786f519fcb3bde Mon Sep 17 00:00:00 2001 +From: gaulthier gain +Date: Fri, 28 Feb 2020 17:05:28 +0000 +Subject: [UNIKRAFT/MUSL] Update __stdout_write to allow flushing on stdout + +Signed-off-by: gaulthier gain +--- + src/stdio/__stdout_write.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c +index dd1ec60..f9c9489 100644 +--- a/src/stdio/__stdout_write.c ++++ b/src/stdio/__stdout_write.c +@@ -6,6 +6,6 @@ size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) + struct winsize wsz; + f->write = __stdio_write; + if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz)) +- f->lbf = -1; ++ f->lbf = '\n'; + return __stdio_write(f, buf, len); + } +-- +2.17.1 + -- 2.39.5