- Timestamp:
- Jul 23, 2011, 7:32:14 PM (13 years ago)
- Parents:
- f661cee (diff), a7fac14 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
rb8a3e00 ra7fac14 389 389 } 390 390 391 #define CHECK_RESULT(s, syscall)\391 #define OR_DIE(s, syscall) \ 392 392 G_STMT_START { \ 393 if ((syscall) != 0) { \393 if ((syscall) == -1) { \ 394 394 perror((s)); \ 395 395 exit(1); \ … … 402 402 sigset_t sigset; 403 403 int ret, i; 404 const int signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGHUP, SIGILL, 405 SIGINT, SIGQUIT, SIGSEGV, SIGTERM, SIGWINCH }; 404 const int reset_signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGILL, 405 SIGQUIT, SIGSEGV, }; 406 /* Don't bother resetting watched ones because owl_signal_init will. */ 407 const int watch_signals[] = { SIGWINCH, SIGTERM, SIGHUP, SIGINT, }; 406 408 407 409 /* Sanitize our signals; the mask and dispositions from our parent 408 410 * aren't really useful. Signal list taken from equivalent code in 409 411 * Chromium. */ 410 CHECK_RESULT("sigemptyset", sigemptyset(&sigset));412 OR_DIE("sigemptyset", sigemptyset(&sigset)); 411 413 if ((ret = pthread_sigmask(SIG_SETMASK, &sigset, NULL)) != 0) { 412 414 errno = ret; 413 415 perror("pthread_sigmask"); 414 } 415 for (i = 0; i < G_N_ELEMENTS(signals); i++) { 416 CHECK_RESULT("sigaction", sigaction(signals[i], &sig_default, NULL)); 416 exit(1); 417 } 418 for (i = 0; i < G_N_ELEMENTS(reset_signals); i++) { 419 OR_DIE("sigaction", sigaction(reset_signals[i], &sig_default, NULL)); 417 420 } 418 421 419 422 /* Turn off SIGPIPE; we check the return value of write. */ 420 CHECK_RESULT("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL));423 OR_DIE("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL)); 421 424 422 425 /* Register some signals with the signal thread. */ 423 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGWINCH)); 424 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGTERM)); 425 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGHUP)); 426 CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGINT)); 427 owl_signal_init(&sigset, sig_handler, NULL); 426 owl_signal_init(watch_signals, G_N_ELEMENTS(watch_signals), 427 sig_handler, NULL); 428 428 } 429 429
Note: See TracChangeset
for help on using the changeset viewer.