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.
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`.
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.
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.
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.
When calling `clone()` with PTRACE_O_TRACEFORK set, make the child
inherit the current ptrace context. Also start the process with SIGSTOP
pending as per the ptrace docs.
This enable strace follow-forks functionality `strace -f`.
We currently implement `TCGETS`, `TCSETS` and `TCSETSW` which operate on
a `Termios` struct. glibc uses the `Termios2` variants of these
syscalls to additionally get the terminal baud rate.
Use a `Termios2` as the main state of the tty. Return that struct
verbatim for the newly implemented `Termios2` ioctls. Convert to/from
the legacy `Termios` struct for the currently implemented ioctls.
If a task has called one of `sys_exit` or `sys_exit_group`, don't follow
the standard syscall exit path. Since the task is dead and it will never
be rescheduled, there's no point in processing the result of sys_exit.
We currently union the UNMASKABLE_SIGNALS set with the new signal mask.
This does the complete opposite of what we wnat, we want to *remove*
those signals from the newly computed signal mask.
This patch removes the UNMASKABLE_SIGNALS set from any newly computed
signal mask.
Make it such that when a ptrace event is hit:
- The current regset is saved in the ptrace state.
- The current task is put to sleep.
- Arrange for a SIGCHLD to be set to the parent.
- Notify any waiters with the appopriate signal.