Commit Graph

295 Commits

Author SHA1 Message Date
Matthew Leach
53dea094e3 Merge pull request #175 from arihant2math/more-interrupts
Make futex wait interruptable
2026-01-24 07:09:17 +00:00
Ashwin Naren
59adc10cee make futex wait interruptable 2026-01-23 10:23:29 -08:00
Ashwin Naren
aa5a9c7b79 fix typos 2026-01-23 01:26:04 -08:00
Ashwin Naren
92efb4cee7 enforce semicolon_if_nothing_returned and uninlined_format_args 2026-01-23 01:26:04 -08:00
Matthew Leach
190bc06994 Merge pull request #160 from arihant2math/mincore 2026-01-21 06:12:40 +00:00
Ashwin Naren
aca5c0db79 implement mincore 2026-01-20 19:52:47 -08:00
Matthew Leach
9eb2fcc185 Merge pull request #172 from arihant2math/sid
Implement sid syscalls
2026-01-20 06:24:27 +00:00
Ashwin Naren
7e2de367a9 update table 2026-01-19 18:36:31 -08:00
Ashwin Naren
06d016eab6 implement sid syscalls 2026-01-19 18:36:00 -08:00
Matthew Leach
76d4d0023f Merge pull request #170 from arihant2math/better-ext4-writing 2026-01-19 16:19:14 +00:00
Matthew Leach
0979e5f71a Merge pull request #171 from arihant2math/fix-intermittent-ci 2026-01-19 16:18:12 +00:00
Ashwin Naren
fb27ed3320 add retry logic to wget 2026-01-18 17:02:52 -08:00
Ashwin Naren
8df12a027c implement truncation 2026-01-18 01:17:19 -08:00
Ashwin Naren
782bef29e6 move fs tests to their own file 2026-01-17 10:24:05 -08:00
Ashwin Naren
8908b1e332 use macro for registration 2026-01-17 10:24:05 -08:00
Matthew Leach
b9fa68d9a3 Merge pull request #167 from hexagonal-sun/fix-interrupt-poll-order 2026-01-17 17:13:15 +00:00
Matthew Leach
3b71fa3d39 signal: interruptible: prioritize wrapped future over signals
Poll the wrapped future first, ensuring that the interrupt logic doesn't
short-circuit a future which is already ready.

This fixes an issue where `sys_wait4` would return `-EINTR` when
receiving a `SIGCHLD`. Since `SIGCHLD` indicates the wait condition
is met, the underlying future is ready and should return the PID
successfully rather than aborting.
2026-01-17 12:10:37 +00:00
Matthew Leach
abccd323ca Merge pull request #164 from hexagonal-sun/tty-signal-fixes
tty signal fixes
2026-01-17 10:27:50 +00:00
Matthew Leach
bc5d1cd91e syscalls: wait4: make interruptable()
Make the `sys_wait4` system call interruptable via signal delivery.

Also include some a test in `usertest` to ensure proper functionality.
2026-01-17 10:22:53 +00:00
Matthew Leach
ecdfd360d1 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 `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.
2026-01-17 10:21:17 +00:00
Matthew Leach
4a88739804 syscalls: tty: read: make interruptable()
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`.
2026-01-17 10:21:17 +00:00
Matthew Leach
612bbdb172 syscalls: pipe: read: make interruptable()
Allow interrupt for `read()` calls on a pipe.  If the syscall is
interrupted simply return `-EINVAL`.

Add a testcase to `usertest` for this case.
2026-01-17 10:21:17 +00:00
Matthew Leach
2655e8e78a syscalls: sleep: make interruptable()
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.
2026-01-17 10:21:17 +00:00
Matthew Leach
770f32c30c process: signals: add interruptable()
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.
2026-01-17 10:21:17 +00:00
Matthew Leach
b5f184a6d9 process: peek_signal: new
Add a new function that allows for peeking at a task's currently pending
signals without consuming the signal.
2026-01-17 10:21:17 +00:00
Matthew Leach
3ba7f668d6 libkernel: error: add Interrupted
Add the `Interrupted` discriminant for the `KernelError` enum. Also map
it to Linux's `EINTR` error value.
2026-01-17 10:21:17 +00:00
Matthew Leach
71d120ebe7 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.
2026-01-17 10:21:17 +00:00
Matthew Leach
798cad0c38 fd_table: don't close CLOEXEC FDs until exec
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.
2026-01-17 10:21:17 +00:00
Matthew Leach
6fc1990597 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.
2026-01-17 10:21:17 +00:00
Matthew Leach
1e91c60f0b Merge pull request #165 from hexagonal-sun/ptrace-follow-forks
ptrace: trace children on fork
2026-01-17 10:19:20 +00:00
Matthew Leach
3932dd96a7 ptrace: trace children on fork
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`.
2026-01-17 08:35:33 +00:00
Ashwin Naren
f4a9512a41 support waiting on a value less than -1 2026-01-16 15:51:47 -08:00
Ashwin Naren
08f42868b2 proper cross-cpu task insertion logic
chooses the CPU with the least weight of both running and runnable tasks
2026-01-16 15:51:35 -08:00
Ashwin Naren
e7a0ec6801 fix proc fs crashing 2026-01-16 15:51:35 -08:00
Ashwin Naren
c6dd7b07c0 partially implement sys_close_range 2026-01-15 08:43:08 -08:00
Matthew Leach
b064c14a88 Merge pull request #155 from arihant2math/timeofday
Proper timeofday implementations
2026-01-15 12:24:50 +00:00
Matthew Leach
4bb3158812 Merge pull request #153 from arihant2math/prctl-updates
Implement more of prctl
2026-01-15 12:24:27 +00:00
Matthew Leach
14e6c4ccf2 Merge pull request #159 from arihant2math/fix-mem-fault-crash
Fix mem fault crash
2026-01-15 12:24:08 +00:00
Matthew Leach
ffe08ce206 Merge pull request #157 from arihant2math/stubs
Fix gnu coreutils `ls -la`
2026-01-15 12:04:00 +00:00
Matthew Leach
af9c77ddcb Merge pull request #158 from arihant2math/fix-strace-panic
Fix `strace` panic
2026-01-15 12:03:07 +00:00
Ashwin Naren
dc33679c54 fix mem fault crash 2026-01-14 15:03:37 -08:00
Ashwin Naren
e3675a9c1f explicitly return not supported for name_to_handle_at and open_by_handle_at 2026-01-14 14:59:08 -08:00
Ashwin Naren
27b960a986 handle tasks finishing 2026-01-14 14:37:48 -08:00
Matthew Leach
2b55e1d972 sycalls: name_to_handle_at: stub
Return EOPNOTSUPP for `sys_name_to_handle_at`.
2026-01-14 14:24:35 -08:00
Matthew Leach
b452d5812c Merge pull request #138 from arihant2math/xattr
Implement xattr syscalls
2026-01-14 19:13:04 +00:00
Ashwin Naren
3e60a57d67 implement xattr syscalls 2026-01-14 10:51:48 -08:00
Ashwin Naren
27f8028315 proper timeofday implementations 2026-01-14 01:13:26 -08:00
Ashwin Naren
82993b05d3 implement PR_CAPBSET_DROP, PR_GET_SECUREBITS, PR_GET_NO_NEW_PRIVS, and PR_CAP_AMBIENT 2026-01-13 23:52:36 -08:00
Ashwin Naren
96fe0378b7 implement F_DUPFD for sys_fcntl 2026-01-13 16:48:33 -08:00
Ashwin Naren
56f3bcd654 add test 2026-01-13 16:48:10 -08:00