[1] | 1 | /* |
---|
| 2 | * signal.h - signal-management related operations |
---|
| 3 | * |
---|
| 4 | * Author Ghassan Almaless (2008,2009,2010,2011,2012) |
---|
| 5 | * Mohamed Lamine Karaoui (2015) |
---|
| 6 | * Alain Greiner (2016) |
---|
| 7 | * |
---|
| 8 | * Copyright (c) UPMC Sorbonne Universites |
---|
| 9 | * |
---|
| 10 | * This file is part of ALMOS-MKH. |
---|
| 11 | * |
---|
| 12 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
| 13 | * under the terms of the GNU General Public License as published by |
---|
| 14 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 15 | * |
---|
| 16 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 19 | * General Public License for more details. |
---|
| 20 | * |
---|
| 21 | * You should have received a copy of the GNU General Public License |
---|
| 22 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
| 23 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #ifndef _SIGNAL_H_ |
---|
| 27 | #define _SIGNAL_H_ |
---|
| 28 | |
---|
| 29 | #include <hal_types.h> |
---|
| 30 | |
---|
| 31 | #define SIG_DEFAULT (void*)0L |
---|
| 32 | #define SIG_IGNORE (void*)1L |
---|
| 33 | #define SIG_ERROR -1L |
---|
| 34 | |
---|
| 35 | #define SIGHUP 1 /*! hangup */ |
---|
| 36 | #define SIGINT 2 /*! interrupt */ |
---|
| 37 | #define SIGQUIT 3 /*! quit */ |
---|
| 38 | #define SIGILL 4 /*! illegal instruction (not reset when caught) */ |
---|
| 39 | #define SIGTRAP 5 /*! trace trap (not reset when caught) */ |
---|
| 40 | #define SIGIOT 6 /*! IOT instruction */ |
---|
| 41 | #define SIGABRT 6 /*! used by abort, replace SIGIOT in the future */ |
---|
| 42 | #define SIGEMT 7 /*! EMT instruction */ |
---|
| 43 | #define SIGFPE 8 /*! floating point exception */ |
---|
| 44 | #define SIGKILL 9 /*! kill (cannot be caught or ignored) */ |
---|
| 45 | #define SIGBUS 10 /*! bus error */ |
---|
| 46 | #define SIGSEGV 11 /*! segmentation violation */ |
---|
| 47 | #define SIGSYS 12 /*! bad argument to system call */ |
---|
| 48 | #define SIGPIPE 13 /*! write on a pipe with no one to read it */ |
---|
| 49 | #define SIGALRM 14 /*! alarm clock */ |
---|
| 50 | #define SIGTERM 15 /*! software termination signal from kill */ |
---|
| 51 | #define SIGURG 16 /*! urgent condition on IO channel */ |
---|
| 52 | #define SIGSTOP 17 /*! sendable stop signal not from tty */ |
---|
| 53 | #define SIGTSTP 18 /*! stop signal from tty */ |
---|
| 54 | #define SIGCONT 19 /*! continue a stopped process */ |
---|
| 55 | #define SIGCHLD 20 /*! to parent on child stop or exit */ |
---|
| 56 | #define SIGCLD 20 /*! System V name for SIGCHLD */ |
---|
| 57 | #define SIGTTIN 21 /*! to readers pgrp upon background tty read */ |
---|
| 58 | #define SIGTTOU 22 /*! like TTIN for output if (tp->t_local<OSTOP) */ |
---|
| 59 | #define SIGIO 23 /*! input/output possible signal */ |
---|
| 60 | #define SIGPOLL SIGIO /*! System V name for SIGIO */ |
---|
| 61 | #define SIGXCPU 24 /*! exceeded CPU time limit */ |
---|
| 62 | #define SIGXFSZ 25 /*! exceeded file size limit */ |
---|
| 63 | #define SIGVTALRM 26 /*! virtual time alarm */ |
---|
| 64 | #define SIGPROF 27 /*! profiling time alarm */ |
---|
| 65 | #define SIGWINCH 28 /*! window changed */ |
---|
| 66 | #define SIGLOST 29 /*! resource lost (eg, record-lock lost) */ |
---|
| 67 | #define SIGUSR1 30 /*! user defined signal 1 */ |
---|
| 68 | #define SIGUSR2 31 /*! user defined signal 2 */ |
---|
| 69 | #define SIG_NR 32 /*! signal 0 implied */ |
---|
| 70 | |
---|
| 71 | #define SIG_DEFAULT_MASK 0xFFEEFFFF |
---|
| 72 | #define SIG_DEFAULT_STACK_SIZE 2048 |
---|
| 73 | |
---|
| 74 | /**** Forward declarations ****/ |
---|
| 75 | |
---|
| 76 | struct process_s; |
---|
| 77 | struct thread_s; |
---|
| 78 | |
---|
| 79 | typedef uint32_t sigval_t; |
---|
| 80 | typedef uint32_t sigset_t; |
---|
| 81 | |
---|
| 82 | /******************************************************************************************* |
---|
| 83 | * This structure ... |
---|
| 84 | ******************************************************************************************/ |
---|
| 85 | |
---|
| 86 | typedef struct siginfo_s |
---|
| 87 | { |
---|
| 88 | int si_signo; /*! Signal number */ |
---|
| 89 | int si_errno; /*! An errno value */ |
---|
| 90 | int si_code; /*! Signal code */ |
---|
| 91 | pid_t si_pid; /*! Sending process ID */ |
---|
| 92 | uid_t si_uid; /*! Real user ID of sending process */ |
---|
| 93 | int si_status; /*! Exit value or signal */ |
---|
| 94 | clock_t si_utime; /*! User time consumed */ |
---|
| 95 | clock_t si_stime; /*! System time consumed */ |
---|
| 96 | sigval_t si_value; /*! Signal value */ |
---|
| 97 | int si_int; /*! POSIX.1b signal */ |
---|
| 98 | void *si_ptr; /*! POSIX.1b signal */ |
---|
| 99 | void *si_addr; /*! Memory location which caused fault */ |
---|
| 100 | int si_band; /*! Band event */ |
---|
| 101 | int si_fd; /*! File descriptor */ |
---|
| 102 | } |
---|
| 103 | siginfo_t; |
---|
| 104 | |
---|
| 105 | /******************************************************************************************* |
---|
| 106 | * This structure ... |
---|
| 107 | ******************************************************************************************/ |
---|
| 108 | |
---|
| 109 | typedef void (sa_handler_t) ( uint32_t sig ); |
---|
| 110 | |
---|
| 111 | typedef struct sigaction_s |
---|
| 112 | { |
---|
| 113 | sigset_t sa_mask; |
---|
| 114 | uint32_t sa_flags; |
---|
| 115 | union |
---|
| 116 | { |
---|
| 117 | sa_handler_t *sa_handler; |
---|
| 118 | void (*sa_sigaction)(int, siginfo_t *, void *); |
---|
| 119 | }; |
---|
| 120 | } |
---|
| 121 | sigaction_t; |
---|
| 122 | |
---|
| 123 | /******************************************************************************************* |
---|
| 124 | * This structure TODO |
---|
| 125 | ******************************************************************************************/ |
---|
| 126 | |
---|
| 127 | typedef struct sig_mgr_s |
---|
| 128 | { |
---|
| 129 | sa_handler_t * sigactions[SIG_NR]; |
---|
[5] | 130 | struct thread_s * handler; |
---|
[1] | 131 | } |
---|
| 132 | sig_mgr_t; |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | /******************************************************************************************* |
---|
| 136 | * This function TODO |
---|
| 137 | ******************************************************************************************/ |
---|
| 138 | int sys_signal ( uint32_t sig, |
---|
| 139 | sa_handler_t * handler ); |
---|
| 140 | |
---|
| 141 | /******************************************************************************************* |
---|
| 142 | * This function TODO |
---|
| 143 | ******************************************************************************************/ |
---|
| 144 | int sys_sigreturn_setup( void * sigreturn_func ); |
---|
| 145 | |
---|
| 146 | /******************************************************************************************* |
---|
[5] | 147 | * This function register the signal <sig> in the bit_vector of all threads of a given |
---|
| 148 | * process identified by its <pid>, in all clusters containing threads for this process. |
---|
| 149 | * It can be executed by any thread running in any cluster, as this function uses |
---|
| 150 | * remote access to traverse the list of process copies, and the RPC_RISE_SIGNAL |
---|
| 151 | * to deliver the signal to all involved clusters. |
---|
| 152 | * The list of process copies is rooted in the owner cluster. |
---|
[1] | 153 | ******************************************************************************************/ |
---|
| 154 | int sys_kill( pid_t pid, |
---|
| 155 | uint32_t sig ); |
---|
| 156 | |
---|
| 157 | /******************************************************************************************* |
---|
| 158 | * This function TODO |
---|
| 159 | ******************************************************************************************/ |
---|
| 160 | error_t signal_manager_init( struct process_s * process ); |
---|
| 161 | |
---|
| 162 | /******************************************************************************************* |
---|
| 163 | * This function register the signal <sig> in the bit-vector of all threads of a given |
---|
[5] | 164 | * process identified by its <pid>, in a given cluster. |
---|
| 165 | * It must be executed by a thread running in the same cluster as the target threads |
---|
| 166 | * (can be a local thread or a RPC thread). |
---|
[1] | 167 | ******************************************************************************************/ |
---|
[5] | 168 | error_t signal_rise( struct process_s * process, |
---|
| 169 | uint32_t sig ); |
---|
[1] | 170 | |
---|
| 171 | /******************************************************************************************* |
---|
| 172 | * This function TODO |
---|
| 173 | ******************************************************************************************/ |
---|
| 174 | void signal_notify( struct thread_s * this); |
---|
| 175 | |
---|
| 176 | /******************************************************************************************* |
---|
| 177 | * This function do nothing in this implementation. |
---|
| 178 | ******************************************************************************************/ |
---|
| 179 | #define signal_manager_destroy(task) |
---|
| 180 | |
---|
| 181 | #endif /*! _SIGNAL_H_ */ |
---|