/* Demonstrate a bus error */ #include #include #include #include void bushandler( int signal ) { printf("Caught bus error %d\n", signal); //return; //infinite loop exit(-1); // gracefully leave program } int main(int argc, char *argv[]) { signal( SIGBUS, bushandler ); // on Mac OS, the literal strings are stored in constant memory, so // we can't write to them. strcpy("hello", "goodbye"); return 0; }