zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.6k stars 6.49k forks source link

libc: implement `signal()` #66927

Open ycsin opened 9 months ago

ycsin commented 9 months ago

This was originally added as a ticket under POSIX, but signal() is not a POSIX function. It is from C89.

https://en.cppreference.com/w/c/program/signal

The expectation from the POSIX API is that this function is implemented as part of whatever C library is in use.

douglashuangg commented 5 months ago

Hey, I'd like to get started on this issue. Any pointers as to how I should tackle this issue?

cfriedt commented 5 months ago

Hey, I'd like to get started on this issue. Any pointers as to how I should tackle this issue?

@douglashuangg - that's a tricky one.

https://pubs.opengroup.org/onlinepubs/007904875/functions/sigaction.html

It was intended that the signal() function should be implementable as a library routine using sigaction().

So you could technically make a very simple wrapper for it.

The caveat is that Zephyr does not currently support processes - so sigaction would be thread to thread.

I have a branch implementing sigaction et al at the kernel level, so the posix sigaction and friends will be fairly simple wrappers around Zephyr syscalls.