-
Notifications
You must be signed in to change notification settings - Fork 70
tty signal fixes #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
tty signal fixes #164
Conversation
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
c57e32c to
5712c97
Compare
arihant2math
approved these changes
Jan 17, 2026
Inherit the process-group ID from the parent. If there is no parent specified then the pgid is the same as the tgid.
Currently we close CLOEXEC FDs when we call `clone()` when making a copy of the file descriptor table. Defer this until the `exec` syscall. This fixes numerous bugs, namely with bash and setting the foreground process group for the current TTY.
If all tasks within a thread group are sleeping when a signal is delivered, wake at least one task to action the signal.
Add the `Interrupted` discriminant for the `KernelError` enum. Also map it to Linux's `EINTR` error value.
Add a new function that allows for peeking at a task's currently pending signals without consuming the signal.
Add a new struct, `InterruptableFut` which allows signal short-circuiting logic. If a future within the kernel's syscall logic is wrapped in a `InterruptableFut`, then a wakeup with any pending signals causes the underlying future to be dropped and it's operation cancelled. Provide a `InterruptResult` enum to allow the caller to know whether the operation was interrupted and allows them to take appropriate action. Typically exiting with `-EINTR`. Finally, provide a blanket implementation for all futures, allowing then to call `.interruptable()` to easily wrap any future.
Allow the `nanosleep` family of functions to be interrupted. When an interruption occures, calculation the remaining duration and write that back to user-space. Add a test to ensure proper functionality into usertest.
Allow interrupt for `read()` calls on a pipe. If the syscall is interrupted simply return `-EINVAL`. Add a testcase to `usertest` for this case.
Allow a `read()` on a tty to be interrupted by a syscall. This is the fundamental fix for making '^C' interrupt a process like `cat` when it's reading from `stdin`.
This function is used to force the scheduler to reschedule another task, avoiding the fast-path exit. Given the sheer number of task state change points in the code, the fast-path exit code has become too brittle. Instead, check that the current task's state is still `Running` before taking the fast-path short-circuit. The cost of one spinlock uncontended lock-unlock cycle is worth the cost of avoiding many subtle scheduling logic bugs.
Make the `sys_wait4` system call interruptable via signal delivery. Also include some a test in `usertest` to ensure proper functionality.
5712c97 to
bc5d1cd
Compare
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.
Fixes: #59
thread_group: pgid: inherit from parent
Inherit the process-group ID from the parent. If there is no parent
specified then the pgid is the same as the tgid.
fd_table: don't close CLOEXEC FDs until exec
Currently we close CLOEXEC FDs when we call
clone()when making a copyof the file descriptor table. Defer this until the
execsyscall.This fixes numerous bugs, namely with bash and setting the foreground
process group for the current TTY.
thread_group: deliver_signal: ensure signal delivery
If all tasks within a thread group are sleeping when a signal is
delivered, wake at least one task to action the signal.
libkernel: error: add
InterruptedAdd the
Interrupteddiscriminant for theKernelErrorenum. Also mapit to Linux's
EINTRerror value.process:
peek_signal: newAdd a new function that allows for peeking at a task's currently pending
signals without consuming the signal.
process: signals: add
interruptable()Add a new struct,
InterruptableFutwhich allows signalshort-circuiting logic. If a future within the kernel's syscall logic is
wrapped in a
InterruptableFut, then a wakeup with any pending signalscauses the underlying future to be dropped and it's operation cancelled.
Provide a
InterruptResultenum to allow the caller to know whether theoperation was interrupted and allows them to take appropriate action.
Typically exiting with
-EINTR.Finally, provide a blanket implementation for all futures, allowing then
to call
.interruptable()to easily wrap any future.usertest: make sleep interruptable()
Allow the
nanosleepfamily of functions to be interrupted. When aninterruption occures, calculation the remaining duration and write that
back to user-space.
Add a test to ensure proper functionality into usertest.
pipe: read: allow interruption
Allow interrupt for
read()calls on a pipe. If the syscall isinterrupted simply return
-EINVAL.Add a testcase to
usertestfor this case.tty: read: allow interruption
Allow a
read()on a tty to be interrupted by a syscall. This is thefundamental fix for making '^C' interrupt a process like
catwhen it'sreading from
stdin.sched: remove
force_resched()This function is used to force the scheduler to reschedule another task,
avoiding the fast-path exit. Given the sheer number of task state
change points in the code, the fast-path exit code has become too
brittle.
Instead, check that the current task's state is still
Runningbeforetaking the fast-path short-circuit. The cost of one spinlock uncontended
lock-unlock cycle is worth the cost of avoiding many subtle scheduling
logic bugs.
sys_wait4: make interruptable
Make the
sys_wait4system call interruptable via signal delivery.Also include some a test in
usertestto ensure proper functionality.