On 2018-02-22 16:13, David Joyner wrote:
clang: error: no such file or directory: 'forksigaltstack.c' clang: error: no input files
Sorry, I obviously forgot to mention the step "copy the attached file forksigaltstack.c to the current working directory" and then run
uname -a gcc forksigaltstack.c -o forksigaltstack && ./forksigaltstack -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <unistd.h> #include <sys/wait.h> static void handler(int sig) { fprintf(stderr, "got signal %i\n", sig); fflush(stderr); _exit(0); } volatile int yes; static void stack_overflow(void) { yes = 1; if (yes) stack_overflow(); if (yes) stack_overflow(); } int main(int argc, char** argv) { static char alt_stack_space[1 << 16]; stack_t ss; ss.ss_sp = alt_stack_space; ss.ss_size = sizeof(alt_stack_space); ss.ss_flags = 0; if (sigaltstack(&ss, NULL)) {perror("sigaltstack"); exit(1);} struct sigaction sa; sa.sa_handler = handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_ONSTACK; if (sigaction(SIGSEGV, &sa, NULL)) {perror("sigaction"); exit(1);} if (sigaction(SIGBUS, &sa, NULL)) {perror("sigaction"); exit(1);} if (sigaction(SIGILL, &sa, NULL)) {perror("sigaction"); exit(1);} pid_t child = fork(); if (!child) { /* Child process */ stack_overflow(); } int status; if (wait(&status) != child) {fputs("wait() did not return child\n", stderr); exit(1);} printf("status = %i\n", status); return 0; }