Skip to content

Support for signals #54

Description

@RobertBendun

Requires #53.

Example

C code showing naive implementation of signals support

#define _GNU_SOURCE
#include <unistd.h>
#include <signal.h>
#include <sys/syscall.h>

void handle(int v)
{
	(void)v;

	syscall(SYS_write, 0, "whatsuppp?\n", 11);
}


#define SA_RESTORER 0x04000000

void restorer()
{
	syscall(SYS_rt_sigreturn);
}

int main()
{
	struct sigaction sa = {};
	sa.sa_handler = handle;
	sigemptyset(&sa.sa_mask);

#if 0
	sigaction(SIGINT, &sa, (void*)0);
#else
	sa.sa_flags |= SA_RESTORER;
	sa.sa_restorer = restorer;
	syscall(SYS_rt_sigaction, SIGINT, &sa, (void*)0, 8);
#endif

	usleep(10 * 1000000);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions