From 1ef1fe8a60ad366631aed6f6e1df68038b1a9f22 Mon Sep 17 00:00:00 2001 From: RarDog Date: Wed, 2 Sep 2026 21:31:12 +0300 Subject: [PATCH] fix(console): route background daemon startup logs to dmesg to keep interactive terminal pristine --- kernel/src/arch/syscall.rs | 11 ++++++++++- servers/sh/main.cpp | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/src/arch/syscall.rs b/kernel/src/arch/syscall.rs index dee27d9..f83840b 100644 --- a/kernel/src/arch/syscall.rs +++ b/kernel/src/arch/syscall.rs @@ -240,7 +240,16 @@ pub extern "C" fn kernel_syscall_dispatcher(regs: &mut SyscallRegisters) { if !msg_ptr.is_null() && len > 0 && len < 4096 { let slice = unsafe { core::slice::from_raw_parts(msg_ptr, len) }; if let Ok(s) = core::str::from_utf8(slice) { - SerialPort.write_str(s); + let is_daemon = unsafe { + let sched = &*core::ptr::addr_of!(SCHEDULER); + let name = sched.threads[sched.current_tid].name; + name.starts_with("gui") || name.starts_with("proc") || name.starts_with("init") + }; + if is_daemon { + crate::drivers::dmesg::append_log(slice); + } else { + SerialPort.write_str(s); + } regs.rax = 0; return; } diff --git a/servers/sh/main.cpp b/servers/sh/main.cpp index 421b162..41be5fa 100644 --- a/servers/sh/main.cpp +++ b/servers/sh/main.cpp @@ -603,10 +603,12 @@ static void handle_command(char *cmd) { } extern "C" void _start() { - for (int i = 0; i < 6; i++) { + // Yield until initial boot modules finish their startup messages + for (int i = 0; i < 15; i++) { sys_yield(); } + // Clean screen after all boot logs are finished sys_log_debug("\033[2J\033[H", 7); print_fastfetch();