Add userland resume path and tty input flush on exec - #35
Merged
pradosh-arduino merged 2 commits intoApr 2, 2026
Merged
Conversation
pradosh-arduino
deleted the
codex/fix-os-userland-return-crash-and-tty-buffer-issue
branch
April 2, 2026 11:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
iretqpath.Description
tty_flush_input()to the TTY API (tty.h) and implemented it to clear the cooked ring buffer and reset the current line (tty.c).tty_flush_input()from the shellexeccommand (exec.c) before invokinguserland_execto clear leftover input.userland_should_return_kernelflag inuserland.c, and save callee-saved registers (rbx,rbp,r12..r15) plus kernelrsp/ripbefore entering userland.userland_prepare_exit()to signal return by settinguserland_should_return_kernelinstead of directly patching a syscall frame.syscalls-x86_64.asm) to checkuserland_should_return_kerneland, if set, restore saved registers andrsp/ripand jump directly to the saved kernel resume address; otherwise perform the normaliretqreturn.userland_running/exit code handling remains intact.Testing
makewhich completed successfully without compilation errors.exec, and observed the kernel print the process exit code and return to the shell, indicating the resume/exit path and TTY flush behaved as expected.Codex Task