feat: add is_terminal_attached syscall

This commit is contained in:
2026-08-27 18:11:21 +02:00
parent 8afadb44cb
commit c8264b92a9
11 changed files with 46 additions and 3 deletions
+4 -1
View File
@@ -626,6 +626,8 @@ namespace montauk::abi {
return 0;
}
case SYS_TERMINAL_ATTACHED:
return Sys_TerminalAttached();
default:
return -1;
}
@@ -652,7 +654,8 @@ namespace montauk::abi {
Hal::WriteMSR(Hal::IA32_FMASK, 0x200);
Kt::KernelLogStream(Kt::OK, "Syscall") << "SYSCALL/SYSRET initialized (LSTAR="
<< kcp::hex << (uint64_t)SyscallEntry << kcp::dec << ", 171 syscall slots)";
<< kcp::hex << (uint64_t)SyscallEntry << kcp::dec << ", "
<< (SYS_TERMINAL_ATTACHED + 1) << " syscall slots)";
}
}
+3
View File
@@ -160,6 +160,9 @@ namespace montauk::abi {
/* Userspace log */
static constexpr uint64_t SYS_LOG_WRITE = 176;
/* Process terminal attachment */
static constexpr uint64_t SYS_TERMINAL_ATTACHED = 177;
// Audio control commands (for SYS_AUDIOCTL).
//
// Commands 0..3 act on the stream named by the handle argument.
+5
View File
@@ -12,6 +12,11 @@
namespace montauk::abi {
static int Sys_TerminalAttached() {
auto* proc = Sched::GetCurrentProcessPtr();
return proc != nullptr && proc->redirected && proc->ioOutHandle >= 0;
}
static void Sys_Print(const char* text) {
auto* proc = Sched::GetCurrentProcessPtr();
if (proc && proc->redirected) {