Skip to content

kernel: support POSIX signals#73

Merged
d4ilyrun merged 10 commits intomasterfrom
xxx-signals
Mar 12, 2026
Merged

kernel: support POSIX signals#73
d4ilyrun merged 10 commits intomasterfrom
xxx-signals

Conversation

@d4ilyrun
Copy link
Owner

No description provided.

@d4ilyrun d4ilyrun force-pushed the xxx-signals branch 2 times, most recently from 55527e3 to 881525a Compare March 12, 2026 02:02
We will need to reuse this structure to foward the state of the
registers to the userland signal handler.

While at it, rename the 'stub' field in the interrupt_frame struct
to 'regs' to make the name more explicit. Same for the 'state' field,
that was renamed to 'frame' since it contains the original interupt
frame pushed by hardware.
Also rename the other linked list node structures inside struct process.
@d4ilyrun d4ilyrun force-pushed the xxx-signals branch 6 times, most recently from 526927f to 310a3d0 Compare March 12, 2026 21:22
This commit adds support for the follwing POSIX syscalls:
- sigaction()
- sigprocmask()
- sigpending()

What is still missing in this implementation:
- Support for process pausing and continuing
- Support for real time syscalls
From POSIX.1-2024:

    The value of status may be 0, EXIT_SUCCESS, EXIT_FAILURE,
    or any other value, though only the least significant 8 bits
    (that is, status & 0377) shall be available from wait() and
    waitpid();

Compute and store the final value in sys_exit() to make regular
exits distinguishable from ones caused by a signal.
This commit defines a few default interrupt handlers that simply
generates the appropriate POSIX signal when a fault occurs.

Such errors should only ever be allowed for userland code. As such,
the handlers call the panic fnuction if the faulting process was
running in kernel mode.

Link: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/signal.h.html
Newlib's configure script hardcodes a few system header directories
that are included before our own header. Patch the configure script
to be able to insert our own system headers (in first place to be able
to use #include_next).

Despite this we are still unable to access our own header directly
in syscalls.c (i have no clue why), so we had to come up with a little
trick until we find a proper solution.
Also implement BSD's killpg() which is defined but not implemented by newlib.
@d4ilyrun d4ilyrun marked this pull request as ready for review March 12, 2026 21:24
@d4ilyrun d4ilyrun merged commit e7f4e98 into master Mar 12, 2026
3 checks passed
@d4ilyrun d4ilyrun deleted the xxx-signals branch March 12, 2026 21:25
@d4ilyrun d4ilyrun mentioned this pull request Mar 12, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant