static void setup_sig_handler(void) { set_handler(SIGHUP); set_handler(SIGPIPE); set_handler(SIGINT); set_handler(SIGSEGV); set_handler(SIGTERM); }
void trap_init(ulong reloc_addr) { unsigned long ebase = gd->irq_sp; set_handler(0x180, &except_vec3_generic, 0x80); set_handler(0x280, &except_vec_ejtag_debug, 0x80); write_c0_ebase(ebase); clear_c0_status(ST0_BEV); execution_hazard_barrier(); }
config_handlers( assert_context_func warn_handler = &default_handle_warn, assert_context_func debug_handler = &default_handle_debug, assert_context_func error_handler = &default_handle_error, assert_context_func enforce_handler = &default_handle_enforce, assert_context_func fatal_handler = &default_handle_fatal) { set_handler( lvl_warn, warn_handler); set_handler( lvl_debug, debug_handler); set_handler( lvl_error, error_handler); set_handler( lvl_enforce, enforce_handler); set_handler( lvl_fatal, fatal_handler); }
void init_new_thread_signals(void) { set_handler(SIGSEGV, (__sighandler_t) sig_handler, SA_ONSTACK, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); set_handler(SIGTRAP, (__sighandler_t) sig_handler, SA_ONSTACK, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); set_handler(SIGFPE, (__sighandler_t) sig_handler, SA_ONSTACK, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); set_handler(SIGILL, (__sighandler_t) sig_handler, SA_ONSTACK, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); set_handler(SIGBUS, (__sighandler_t) sig_handler, SA_ONSTACK, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); signal(SIGHUP, SIG_IGN); init_irq_signals(1); }
int anna(const char * hostname) { int success; struct sockaddr_in address; struct timeval wait_time = { 1, 0 }; succeed_or_die(success, 0, get_ipv4(hostname, IPPROTO_ICMP, &address)); int sockfd; succeed_or_die(success, 0, create_raw_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP, &sockfd)); set_handler(); int i; for (i = 0; fin_des_temps == 1; i++) { printf("Discovering new route:\n"); printf("----------------------\n"); succeed_or_die(success, 0, traceroute_icmp_v4(hostname, 64, 3, 64, &wait_time)); printf("\n"); printf("Pinging:\n"); printf("--------\n"); ping_v4(hostname); printf("\n"); } printf("traceroute and pinging done %d time(s).\n", i); close(sockfd); return success; }
void MsqInterrupt::allow( MsqError& /*err*/ ) { sawInterrupt = false; interruptMode = AUTO; if (instanceCount && SIG_ERR == oldHandler) set_handler(); }
void ciBlock::set_exception_range(int start_bci, int limit_bci) { assert(limit_bci >= start_bci, "valid range"); assert(!is_handler() && _ex_start_bci == -1 && _ex_limit_bci == -1, "must not be handler"); _ex_start_bci = start_bci; _ex_limit_bci = limit_bci; set_handler(); }
/* * Generate file descriptor sets */ void GenerateFDSets(int *nfds, fd_set *rfds, fd_set *wfds, fd_set *efds) { handler * h; *nfds = 0; FD_ZERO(rfds); FD_ZERO(wfds); FD_ZERO(efds); for (set_handler(); (h = get_handler()) != NULL; ) { if (IS_FILE_HANDLER(h) && !IS_DISPOSED(h)) { if (IS_FILE_READ_HANDLER(h)) { FD_SET(h->fd, rfds); } if (IS_FILE_WRITE_HANDLER(h)) { FD_SET(h->fd, wfds); } if (IS_FILE_EXCEPT_HANDLER(h)) { FD_SET(h->fd, efds); } if (h->fd > *nfds) { *nfds = h->fd; } } } }
int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) { sigjmp_buf **switch_buf = switch_buf_ptr; int n; set_handler(SIGWINCH, (__sighandler_t) sig_handler, SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGALRM, SIGVTALRM, -1); *fork_buf_ptr = &initial_jmpbuf; n = sigsetjmp(initial_jmpbuf, 1); switch(n){ case INIT_JMP_NEW_THREAD: new_thread_proc((void *) stack, new_thread_handler); break; case INIT_JMP_REMOVE_SIGSTACK: remove_sigstack(); break; case INIT_JMP_CALLBACK: (*cb_proc)(cb_arg); siglongjmp(*cb_back, 1); break; case INIT_JMP_HALT: kmalloc_ok = 0; return(0); case INIT_JMP_REBOOT: kmalloc_ok = 0; return(1); default: panic("Bad sigsetjmp return in start_idle_thread - %d\n", n); } siglongjmp(**switch_buf, 1); }
int main(int ac, char **av) { int signal, flag; int lc; char *msg; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); tst_exit(); } setup(); for (lc = 0; TEST_LOOPING(lc); ++lc) { Tst_count = 0; for (testno = 0; testno < TST_TOTAL; ++testno) { for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++) {//signal for 34 to 65 for (flag=0; flag<5;flag++) { TEST(set_handler(signal, 0, test_flags[flag])); if ((TEST_RETURN == -1) && (TEST_ERRNO == test_cases[0].exp_errno)) { tst_resm(TINFO, "sa.sa_flags = %s ",test_flags_list[flag]); tst_resm(TPASS, "%s failure with sig: %d as expected errno = %s : %s", TCID, signal,test_cases[0].errdesc, strerror(TEST_ERRNO)); } else { tst_resm(TFAIL, "rt_sigaction call succeeded: result = %ld got error %d:but expected %d", TEST_RETURN, TEST_ERRNO, test_cases[0].exp_errno); tst_resm(TINFO, "sa.sa_flags = %s ",test_flags_list[flag]); } } printf("\n"); } } } cleanup(); tst_exit(); }
void MsqInterrupt::enable( MsqError& /*err*/ ) { sawInterrupt = false; interruptMode = CATCH; if (instanceCount && SIG_ERR == oldHandler) set_handler(); }
int main(void) { printf ("My pid is %d\n", getpid()); printf ( "Signal managed : SIGTALRM(intern), SIGUSR1(30), SIGUSR2(31)\n"); set_handler (SIGALRM, handler_sigalrm, NULL); set_handler (SIGUSR1, handler_sigusr1, NULL); set_handler (SIGUSR2, handler_sigusr2, NULL); printf ("Start timer\n"); arm_timer (ITIMER_REAL, (long)ALRM_S, (long)ALRM_U, 1); sigpause (sigmask(SIGALRM) | sigmask(SIGUSR1)); printf ("Done.\n"); exit(0); }
MsqInterrupt::MsqInterrupt() { if (!instanceCount) { if (IGNORE != interruptMode) set_handler(); sawInterrupt = false; } ++instanceCount; }
/* Create the Txn data structure and the continuation for the Txn. */ TSCont TxnSMCreate(TSMutex pmutex, TSVConn client_vc, int server_port) { TSCont contp; TxnSM *txn_sm; txn_sm = (TxnSM *)TSmalloc(sizeof(TxnSM)); txn_sm->q_mutex = pmutex; txn_sm->q_pending_action = NULL; /* Txn will use this server port to connect to the origin server. */ txn_sm->q_server_port = server_port; /* The client_vc is returned by TSNetAccept, refer to Protocol.c. */ txn_sm->q_client_vc = client_vc; /* The server_vc will be created if Txn connects to the origin server. */ txn_sm->q_server_vc = NULL; txn_sm->q_client_read_vio = NULL; txn_sm->q_client_write_vio = NULL; txn_sm->q_client_request_buffer = NULL; txn_sm->q_client_response_buffer = NULL; txn_sm->q_client_request_buffer_reader = NULL; txn_sm->q_client_response_buffer_reader = NULL; txn_sm->q_server_read_vio = NULL; txn_sm->q_server_write_vio = NULL; txn_sm->q_server_request_buffer = NULL; txn_sm->q_server_response_buffer = NULL; txn_sm->q_server_request_buffer_reader = NULL; /* Char buffers to store client request and server response. */ txn_sm->q_client_request = (char *)TSmalloc(sizeof(char) * (MAX_REQUEST_LENGTH + 1)); memset(txn_sm->q_client_request, '\0', (sizeof(char) * (MAX_REQUEST_LENGTH + 1))); txn_sm->q_server_response = NULL; txn_sm->q_server_response_length = 0; txn_sm->q_block_bytes_read = 0; txn_sm->q_cache_vc = NULL; txn_sm->q_cache_response_length = 0; txn_sm->q_cache_read_buffer = NULL; txn_sm->q_cache_read_buffer_reader = NULL; txn_sm->q_server_name = (char *)TSmalloc(sizeof(char) * (MAX_SERVER_NAME_LENGTH + 1)); txn_sm->q_file_name = (char *)TSmalloc(sizeof(char) * (MAX_FILE_NAME_LENGTH + 1)); txn_sm->q_key = NULL; txn_sm->q_magic = TXN_SM_ALIVE; /* Set the current handler to be state_start. */ set_handler(txn_sm->q_current_handler, &state_start); contp = TSContCreate(main_handler, txn_sm->q_mutex); TSContDataSet(contp, txn_sm); return contp; }
void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) { int flags = 0, pages; if(sig_stack != NULL){ pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER); set_sigstack(sig_stack, pages * page_size()); flags = SA_ONSTACK; } if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1); }
/** * Unregister file descriptor handler * Can be called from callback function. */ void UnregisterFileHandler(int fd) { handler * h; for (set_handler(); (h = get_handler()) != NULL; ) { if (IS_FILE_HANDLER(h) && h->fd == fd) { h->htype |= HANDLER_DISPOSED; } } }
int main(int ac, char **av) { int lc; char *msg; /* message got from parse_opts */ int i; int test_flags[] = { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO, SA_RESETHAND | SA_SIGINFO }; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { /* reset Tst_count in case we are looping */ Tst_count = 0; testcase_no = 0; for (i = 0; i < TST_TOTAL; i++) { if (set_handler(test_flags[i], 0) == 0) { if (STD_FUNCTIONAL_TEST) { testcase_no++; switch (i) { case 0: /*FALLTHROUGH*/ case 1: (void)kill(getpid(), SIGUSR1); break; case 2: /*FALLTHROUGH*/ case 3: (void) pthread_kill(pthread_self(), SIGUSR1); break; default: tst_brkm(TBROK, cleanup, "illegal case number"); break; } } else { tst_resm(TPASS, "call succeeded"); } } } } cleanup(); tst_exit(); }
result_t SslHandler::init(X509Cert_base* crt, PKey_base* key, Handler_base* hdlr) { result_t hr; set_handler(hdlr); hr = SslSocket_base::_new(crt, key, m_socket); if (hr < 0) return hr; m_socket->set_verification(ssl_base::_VERIFY_NONE); return 0; }
/** * Unregister file descriptor handler. * Can be called from callback function. */ void UnregisterEventHandler(int type, void (*event_callback)(void *, void *)) { handler * h; for (set_handler(); (h = get_handler()) != NULL; ) { if (IS_EVENT_HANDLER(h) && h->event_type == type && h->event_handler == event_callback) { h->htype |= HANDLER_DISPOSED; } } }
result_t SslHandler::init(v8::Local<v8::Array> certs, Handler_base* hdlr) { result_t hr; set_handler(hdlr); hr = SslSocket_base::_new(certs, m_socket); if (hr < 0) return hr; m_socket->set_verification(ssl_base::_VERIFY_NONE); return 0; }
int main(int ac, char **av) { unsigned int flag; int signal; int lc; tst_parse_opts(ac, av, NULL, NULL); setup(); for (lc = 0; TEST_LOOPING(lc); ++lc) { tst_count = 0; for (testno = 0; testno < TST_TOTAL; ++testno) { for (signal = SIGRTMIN; signal <= (SIGRTMAX); signal++) { tst_resm(TINFO, "Signal %d", signal); for (flag = 0; flag < ARRAY_SIZE(test_flags); flag++) { TEST(set_handler (signal, 0, test_flags[flag])); if ((TEST_RETURN == -1) && (TEST_ERRNO == test_cases[0].exp_errno)) { tst_resm(TINFO, "sa.sa_flags = %s ", test_flags_list[flag]); tst_resm(TPASS, "%s failure with sig: %d as expected errno = %s : %s", TCID, signal, test_cases[0].errdesc, strerror(TEST_ERRNO)); } else { tst_resm(TFAIL, "rt_sigaction call succeeded: result = %ld got error %d:but expected %d", TEST_RETURN, TEST_ERRNO, test_cases[0]. exp_errno); tst_resm(TINFO, "sa.sa_flags = %s ", test_flags_list[flag]); } } } } } cleanup(); tst_exit(); }
Signaling::Signaling(SignalSet signalSet, SignalHandler& handler ) throw(Signaling::Error) { memcpy(oldSignalHandlers_, currentSignalHandlers_, sizeof(currentSignalHandlers_)); oldSignalMask_ = currentSignalMask_; currentSignalMask_ = signalSet; for( int i = 0; i < SignalSet::sNSIG; i++ ) { if ( currentSignalMask_.isBitSet( i ) ) { currentSignalHandlers_[i] = &handler; set_handler( SignalSet::bitNumber2signal(i), call_handler ); } } currentSignalMask_ |= oldSignalMask_; }
void apply(sender& s) { if (s.uninitialized()) { if (delivery_mode.set) set_delivery_mode(s, delivery_mode.value); if (handler.set && handler.value) set_handler(s, *handler.value); if (auto_settle.set) get_context(s).auto_settle = auto_settle.value; if (source.set) { proton::source local_s(make_wrapper<proton::source>(pn_link_source(unwrap(s)))); source.value.apply(local_s); } if (target.set) { proton::target local_t(make_wrapper<proton::target>(pn_link_target(unwrap(s)))); target.value.apply(local_t); } } }
extern "C" cons_t* proc_deactivate_signal(cons_t* p, environment_t*) { assert_length(p, 1); assert_type(INTEGER, car(p)); integer_t sig = car(p)->number.integer; if ( sig<0 || sig > SIGHANDLERS ) raise(runtime_exception(format("Invalid signal: %d", sig))); if ( SIG_ERR == set_handler(sig, NULL) ) raise(runtime_exception(strerror(errno))); return nil(); }
/** * Call all event handlers of a particular type */ void CallEventHandlers(int type, void *data) { handler * h; for (set_handler(); (h = get_handler()) != NULL; ) { if (IS_EVENT_HANDLER(h)) { if (IS_DISPOSED(h)) { dispose_handler(h); } else if (h->event_type == type) { h->event_handler(h->data, data); } } } }
int main(int ac, char **av) { int signal, flag; int lc; char *msg; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); } setup(); for (lc = 0; TEST_LOOPING(lc); ++lc) { Tst_count = 0; for (testno = 0; testno < TST_TOTAL; ++testno) { for (signal = SIGRTMIN; signal <= (SIGRTMAX ); signal++) {//signal for 34 to 65 #ifdef __x86_64__ sig_initial(signal); #endif for (flag = 0; flag < (sizeof(test_flags) / sizeof(test_flags[0])); flag++) { TEST(set_handler(signal, 0, test_flags[flag])); if (TEST_RETURN == 0) { tst_resm(TINFO,"signal: %d ", signal); tst_resm(TPASS, "rt_sigaction call succeeded: result = %ld ",TEST_RETURN ); tst_resm(TINFO, "sa.sa_flags = %s ",test_flags_list[flag]); kill(getpid(),signal); } else { tst_resm(TFAIL | TTERRNO, "rt_sigaction call " "failed"); } } } } } cleanup(); tst_exit(); }
void init_new_thread_signals(void) { set_handler(SIGSEGV); set_handler(SIGTRAP); set_handler(SIGFPE); set_handler(SIGILL); set_handler(SIGBUS); signal(SIGHUP, SIG_IGN); set_handler(SIGIO); signal(SIGWINCH, SIG_IGN); }
extern "C" cons_t* proc_signal(cons_t* p, environment_t*) { assert_length(p, 2); assert_type(INTEGER, car(p)); assert_type(CLOSURE, cadr(p)); integer_t sig = car(p)->number.integer; closure_t* func = cadr(p)->closure; if ( sig<0 || sig > SIGHANDLERS ) raise(runtime_exception(format("Invalid signal: %d", sig))); if ( SIG_ERR == set_handler(sig, func) ) raise(runtime_exception(format("signal: %s", strerror(errno)))); return nil(); }
/********************************************************************** * SIGNAL_Init */ BOOL SIGNAL_Init(void) { if (set_handler( SIGINT, (void (*)())int_handler ) == -1) goto error; if (set_handler( SIGFPE, (void (*)())fpe_handler ) == -1) goto error; if (set_handler( SIGSEGV, (void (*)())segv_handler ) == -1) goto error; if (set_handler( SIGILL, (void (*)())ill_handler ) == -1) goto error; if (set_handler( SIGBUS, (void (*)())bus_handler ) == -1) goto error; if (set_handler( SIGTRAP, (void (*)())trap_handler ) == -1) goto error; if (set_handler( SIGABRT, (void (*)())abrt_handler ) == -1) goto error; if (set_handler( SIGQUIT, (void (*)())quit_handler ) == -1) goto error; if (set_handler( SIGUSR1, (void (*)())usr1_handler ) == -1) goto error; /* 'ta 6' tells the kernel to synthesize any unaligned accesses this process makes, instead of just signalling an error and terminating the process. wine-devel did not reach a conclusion on whether this is correct, because that is what x86 does, or it is harmful because it could obscure problems in user code */ asm("ta 6"); /* 6 == ST_FIX_ALIGN defined in sys/trap.h */ return TRUE; error: perror("sigaction"); return FALSE; }
result_t SslHandler::init(X509Cert_base *crt, PKey_base *key, v8::Local<v8::Value> hdlr) { result_t hr; obj_ptr<Handler_base> hdlr1; hr = JSHandler::New(hdlr, hdlr1); if (hr < 0) return hr; set_handler(hdlr1); hr = SslSocket_base::_new(crt, key, m_socket); if (hr < 0) return hr; m_socket->set_verification(ssl_base::_VERIFY_NONE); return 0; }