Changeset 39457 for trunk/Ohana/src/opihi/lib.shell/interrupt.c
- Timestamp:
- Mar 11, 2016, 10:23:42 PM (10 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/opihi/lib.shell/interrupt.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
-
Property svn:mergeinfo
set to
/branches/eam_branches/ohana.20160226 merged eligible
-
Property svn:mergeinfo
set to
-
trunk/Ohana/src/opihi/lib.shell/interrupt.c
r27611 r39457 7 7 8 8 void handle_interrupt (int input) { 9 OHANA_UNUSED_PARAM(input); 9 10 10 11 char string[64]; 11 12 int Nask; 12 13 13 signal (SIGINT, SIG_IGN);14 // signal (SIGINT, SIG_IGN); 14 15 15 16 Nask = 0; … … 31 32 if ((string[0] == 'y') || (string[0] == 'Y')) { 32 33 interrupt = FALSE; 33 signal (SIGINT, handle_interrupt);34 // signal (SIGINT, handle_interrupt); 34 35 Nint = 0; 35 36 return; … … 38 39 if ((string[0] == 'n') || (string[0] == 'N')) { 39 40 interrupt = TRUE; 40 signal (SIGINT, handle_interrupt);41 // signal (SIGINT, handle_interrupt); 41 42 Nint = 0; 42 43 return; … … 45 46 if (Nask > 3) { 46 47 interrupt = TRUE; 47 signal (SIGINT, handle_interrupt);48 // signal (SIGINT, handle_interrupt); 48 49 Nint = 0; 49 50 return; … … 52 53 53 54 } 55 56 struct 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 77 int 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.
