Change sigaction_f to match sysv signature (#585)

This commit is contained in:
Gavin Hayes 2022-09-02 08:08:35 -04:00 committed by GitHub
parent 33b5b5b312
commit 263711965f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 46 additions and 35 deletions

View file

@ -966,10 +966,11 @@ static privileged int HasSyscall(struct Pledges *p, uint16_t n) {
return 0;
}
static privileged void OnSigSys(int sig, siginfo_t *si, ucontext_t *ctx) {
static privileged void OnSigSys(int sig, siginfo_t *si, void *vctx) {
bool found;
char ord[17], rip[17];
int i, ok, mode = si->si_errno;
ucontext_t *ctx = vctx;
ctx->uc_mcontext.rax = -Eperm;
FixCpy(ord, si->si_syscall, 12);
HexCpy(rip, ctx->uc_mcontext.rip);

View file

@ -251,7 +251,7 @@ static int __sigaction(int sig, const struct sigaction *act,
/**
* Installs handler for kernel interrupt to thread, e.g.:
*
* void GotCtrlC(int sig, siginfo_t *si, ucontext_t *ctx);
* void GotCtrlC(int sig, siginfo_t *si, void *ctx);
* struct sigaction sa = {.sa_sigaction = GotCtrlC,
* .sa_flags = SA_RESETHAND|SA_RESTART|SA_SIGINFO};
* CHECK_NE(-1, sigaction(SIGINT, &sa, NULL));
@ -259,10 +259,11 @@ static int __sigaction(int sig, const struct sigaction *act,
* The following flags are supported across platforms:
*
* - `SA_SIGINFO`: Causes the `siginfo_t` and `ucontext_t` parameters to
* be passed. This not only gives you more information about the
* signal, but also allows your signal handler to change the CPU
* registers. That's useful for recovering from crashes. If you don't
* use this attribute, then signal delivery will go a little faster.
* be passed. `void *ctx` actually refers to `struct ucontext *`.
* This not only gives you more information about the signal, but also
* allows your signal handler to change the CPU registers. That's
* useful for recovering from crashes. If you don't use this attribute,
* then signal delivery will go a little faster.
*
* - `SA_RESTART`: Enables BSD signal handling semantics. Normally i/o
* entrypoints check for pending signals to deliver. If one gets
@ -371,7 +372,8 @@ static int __sigaction(int sig, const struct sigaction *act,
* ctx->uc_mcontext.rip += xedd.length;
* }
*
* void OnCrash(int sig, struct siginfo *si, struct ucontext *ctx) {
* void OnCrash(int sig, struct siginfo *si, void *vctx) {
* struct ucontext *ctx = vctx;
* SkipOverFaultingInstruction(ctx);
* ContinueOnCrash(); // reinstall here in case *rip faults
* }

View file

@ -9,7 +9,8 @@
COSMOPOLITAN_C_START_
typedef void (*sighandler_t)(int);
typedef void (*sigaction_f)(int, struct siginfo *, struct ucontext *);
typedef void (*sigaction_f)(int, struct siginfo *,
void * /*struct ucontext **/);
struct sigaction { /* cosmo abi */
union {

View file

@ -16,12 +16,12 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/bits.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/siginfo.h"
#include "libc/calls/ucontext.h"
#include "libc/dce.h"
#include "libc/intrin/bits.h"
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
@ -41,8 +41,7 @@ static const int sigs[] = {
SIGTERM /* kill (default signal) */
};
textexit static void __onkill(int sig, struct siginfo *si,
struct ucontext *context) {
textexit static void __onkill(int sig, struct siginfo *si, void *context) {
/* https://www.tldp.org/LDP/abs/html/exitcodes.html */
exit(128 + sig);
unreachable;