- Timestamp:
- May 23, 2011, 8:57:46 PM (13 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 257b9c4
- Parents:
- 959cb85
- git-author:
- David Benjamin <davidben@mit.edu> (02/26/11 00:15:35)
- git-committer:
- David Benjamin <davidben@mit.edu> (05/23/11 20:57:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
r6b4033f r3535a6e 354 354 } 355 355 356 void sig_handler(int sig, siginfo_t *si, void *data) 357 { 358 if (sig==SIGWINCH) { 356 static void sig_handler(int sig, void *data) { 357 owl_function_debugmsg("Got signal %d", sig); 358 /* TODO: These don't need to be re-entrant anymore! */ 359 if (sig == SIGWINCH) { 359 360 /* we can't inturrupt a malloc here, so it just sets a flag 360 361 * schedulding a resize for later 361 362 */ 362 363 owl_function_resize(); 363 } else if (sig==SIGPIPE || sig==SIGCHLD) { 364 /* Set a flag and some info that we got the sigpipe 365 * so we can record that we got it and why... */ 366 owl_global_set_errsignal(&g, sig, si); 367 } else if (sig==SIGTERM || sig==SIGHUP) { 364 } else if (sig == SIGPIPE || sig == SIGCHLD) { 365 owl_function_error("Got unexpected signal: %d %s", 366 sig, (sig == SIGPIPE) ? "SIGPIPE" : "SIGCHLD"); 367 } else if (sig == SIGTERM || sig == SIGHUP) { 368 368 owl_function_quit(); 369 } 370 } 371 372 void sigint_handler(int sig, siginfo_t *si, void *data) 373 { 374 owl_global_set_interrupted(&g); 375 } 376 377 static int owl_errsignal_pre_select_action(owl_ps_action *a, void *data) 378 { 379 siginfo_t si; 380 int signum; 381 if ((signum = owl_global_get_errsignal_and_clear(&g, &si)) > 0) { 382 owl_function_error("Got unexpected signal: %d %s (code: %d band: %ld errno: %d)", 383 signum, signum==SIGPIPE?"SIGPIPE":"SIG????", 384 si.si_code, si.si_band, si.si_errno); 385 } 386 return 0; 369 } else if (sig == SIGINT) { 370 owl_input in; 371 in.ch = in.uch = owl_global_get_startup_tio(&g)->c_cc[VINTR]; 372 owl_process_input_char(in); 373 } 387 374 } 388 375 389 376 void owl_register_signal_handlers(void) { 390 struct sigaction sigact; 391 392 /* signal handler */ 393 /*sigact.sa_handler=sig_handler;*/ 394 sigact.sa_sigaction=sig_handler; 395 sigemptyset(&sigact.sa_mask); 396 sigact.sa_flags=SA_SIGINFO; 397 sigaction(SIGWINCH, &sigact, NULL); 398 sigaction(SIGALRM, &sigact, NULL); 399 sigaction(SIGPIPE, &sigact, NULL); 400 sigaction(SIGTERM, &sigact, NULL); 401 sigaction(SIGHUP, &sigact, NULL); 402 403 sigact.sa_sigaction=sigint_handler; 404 sigaction(SIGINT, &sigact, NULL); 377 sigset_t sigset; 378 379 sigemptyset(&sigset); 380 sigaddset(&sigset, SIGWINCH); 381 sigaddset(&sigset, SIGALRM); 382 sigaddset(&sigset, SIGPIPE); 383 sigaddset(&sigset, SIGTERM); 384 sigaddset(&sigset, SIGHUP); 385 sigaddset(&sigset, SIGINT); 386 387 owl_signal_init(&sigset, sig_handler, NULL); 405 388 } 406 389 … … 479 462 g.load_initial_subs = opts.load_initial_subs; 480 463 481 owl_register_signal_handlers();482 464 owl_start_curses(); 483 465 … … 491 473 g_strfreev(argv_copy); 492 474 owl_global_set_haveaim(&g); 475 476 owl_register_signal_handlers(); 493 477 494 478 /* register STDIN dispatch; throw away return, we won't need it */ … … 591 575 g_source_unref(source); 592 576 593 owl_select_add_pre_select_action(owl_errsignal_pre_select_action, NULL, NULL);594 595 577 owl_function_debugmsg("startup: entering main loop"); 596 578 owl_select_run_loop();
Note: See TracChangeset
for help on using the changeset viewer.