IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 11, 2016, 10:23:42 PM (10 years ago)
Author:
eugene
Message:

modify to pass with extremely pedantic build; force consistency for signed vs unsigned and int sizes; various relastro updates

Location:
trunk/Ohana
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/opihi/lib.shell/interrupt.c

    r27611 r39457  
    77
    88void handle_interrupt (int input) {
     9  OHANA_UNUSED_PARAM(input);
    910 
    1011  char string[64];
    1112  int Nask;
    1213
    13   signal (SIGINT, SIG_IGN);
     14  // signal (SIGINT, SIG_IGN);
    1415
    1516  Nask = 0;
     
    3132    if ((string[0] == 'y') || (string[0] == 'Y')) {
    3233      interrupt = FALSE;
    33       signal (SIGINT, handle_interrupt);
     34      // signal (SIGINT, handle_interrupt);
    3435      Nint = 0;
    3536      return;
     
    3839    if ((string[0] == 'n') || (string[0] == 'N')) {
    3940      interrupt = TRUE;
    40       signal (SIGINT, handle_interrupt);
     41      // signal (SIGINT, handle_interrupt);
    4142      Nint = 0;
    4243      return;
     
    4546    if (Nask > 3) {
    4647      interrupt = TRUE;
    47       signal (SIGINT, handle_interrupt);
     48      // signal (SIGINT, handle_interrupt);
    4849      Nint = 0;
    4950      return;
     
    5253
    5354}
     55
     56struct sigaction *SetInterrupt () {
     57
     58  struct sigaction  new_sigaction;
     59  struct sigaction *old_sigaction;
     60
     61  ALLOCATE (old_sigaction, struct sigaction, 1);
     62
     63  new_sigaction.sa_handler = handle_interrupt;
     64  new_sigaction.sa_flags = 0;
     65
     66  int sigstat = sigaction (SIGINT, &new_sigaction, old_sigaction);
     67  if (sigstat) {
     68    perror ("failed to set signal handler: ");
     69    free (old_sigaction);
     70    return NULL;
     71  }
     72
     73  interrupt = FALSE;
     74  return old_sigaction;
     75}
     76
     77int ClearInterrupt (struct sigaction *old_sigaction) {
     78
     79  // interrupt = FALSE;
     80
     81  if (!old_sigaction) return TRUE;
     82
     83  struct sigaction new_sigaction;
     84
     85  if (sigaction (SIGINT, old_sigaction, &new_sigaction)) {
     86    perror ("failed to reset signal handler: ");
     87    FREE (old_sigaction);
     88    return FALSE;
     89  }
     90  FREE (old_sigaction);
     91
     92  return TRUE;
     93}
Note: See TracChangeset for help on using the changeset viewer.