Subversion Repositories Kolibri OS

Rev

Rev 4874 | Rev 6099 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /* sys/signal.h */
  2.  
  3. #ifndef _SYS_SIGNAL_H
  4. #define _SYS_SIGNAL_H
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8.  
  9. #include "_ansi.h"
  10. #include <sys/features.h>
  11. #include <sys/types.h>
  12.  
  13. /* #ifndef __STRICT_ANSI__*/
  14.  
  15. /* Cygwin defines it's own sigset_t in include/cygwin/signal.h */
  16. #ifndef __CYGWIN__
  17. typedef unsigned long sigset_t;
  18. #endif
  19.  
  20. #if defined(__rtems__)
  21.  
  22. #if defined(_POSIX_REALTIME_SIGNALS)
  23.  
  24. /* sigev_notify values
  25.    NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD.  */
  26.  
  27. #define SIGEV_NONE   1  /* No asynchronous notification shall be delivered */
  28.                         /*   when the event of interest occurs. */
  29. #define SIGEV_SIGNAL 2  /* A queued signal, with an application defined */
  30.                         /*  value, shall be delivered when the event of */
  31.                         /*  interest occurs. */
  32. #define SIGEV_THREAD 3  /* A notification function shall be called to */
  33.                         /*   perform notification. */
  34.  
  35. /*  Signal Generation and Delivery, P1003.1b-1993, p. 63
  36.     NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
  37.           sigev_notify_attributes to the sigevent structure.  */
  38.  
  39. union sigval {
  40.   int    sival_int;    /* Integer signal value */
  41.   void  *sival_ptr;    /* Pointer signal value */
  42. };
  43.  
  44. struct sigevent {
  45.   int              sigev_notify;               /* Notification type */
  46.   int              sigev_signo;                /* Signal number */
  47.   union sigval     sigev_value;                /* Signal value */
  48.  
  49. #if defined(_POSIX_THREADS)
  50.   void           (*sigev_notify_function)( union sigval );
  51.                                                /* Notification function */
  52.   pthread_attr_t  *sigev_notify_attributes;    /* Notification Attributes */
  53. #endif
  54. };
  55.  
  56. /* Signal Actions, P1003.1b-1993, p. 64 */
  57. /* si_code values, p. 66 */
  58.  
  59. #define SI_USER    1    /* Sent by a user. kill(), abort(), etc */
  60. #define SI_QUEUE   2    /* Sent by sigqueue() */
  61. #define SI_TIMER   3    /* Sent by expiration of a timer_settime() timer */
  62. #define SI_ASYNCIO 4    /* Indicates completion of asycnhronous IO */
  63. #define SI_MESGQ   5    /* Indicates arrival of a message at an empty queue */
  64.  
  65. typedef struct {
  66.   int          si_signo;    /* Signal number */
  67.   int          si_code;     /* Cause of the signal */
  68.   union sigval si_value;    /* Signal value */
  69. } siginfo_t;
  70. #endif
  71.  
  72. /*  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */
  73.  
  74. #define SA_NOCLDSTOP 1   /* Do not generate SIGCHLD when children stop */
  75. #define SA_SIGINFO   2   /* Invoke the signal catching function with */
  76.                          /*   three arguments instead of one. */
  77.  
  78. /* struct sigaction notes from POSIX:
  79.  *
  80.  *  (1) Routines stored in sa_handler should take a single int as
  81.  *      their argument although the POSIX standard does not require this.
  82.  *      This is not longer true since at least POSIX.1-2008
  83.  *  (2) The fields sa_handler and sa_sigaction may overlap, and a conforming
  84.  *      application should not use both simultaneously.
  85.  */
  86.  
  87. typedef void (*_sig_func_ptr)(int);
  88.  
  89. struct sigaction {
  90.   int         sa_flags;       /* Special flags to affect behavior of signal */
  91.   sigset_t    sa_mask;        /* Additional set of signals to be blocked */
  92.                               /*   during execution of signal-catching */
  93.                               /*   function. */
  94.   union {
  95.     _sig_func_ptr _handler;  /* SIG_DFL, SIG_IGN, or pointer to a function */
  96. #if defined(_POSIX_REALTIME_SIGNALS)
  97.     void      (*_sigaction)( int, siginfo_t *, void * );
  98. #endif
  99.   } _signal_handlers;
  100. };
  101.  
  102. #define sa_handler    _signal_handlers._handler
  103. #if defined(_POSIX_REALTIME_SIGNALS)
  104. #define sa_sigaction  _signal_handlers._sigaction
  105. #endif
  106.  
  107. #elif defined(__CYGWIN__)
  108. #include <cygwin/signal.h>
  109. #else
  110. #define SA_NOCLDSTOP 1  /* only value supported now for sa_flags */
  111.  
  112. typedef void (*_sig_func_ptr)(int);
  113.  
  114. struct sigaction
  115. {
  116.         _sig_func_ptr sa_handler;
  117.         sigset_t sa_mask;
  118.         int sa_flags;
  119. };
  120. #endif /* defined(__rtems__) */
  121.  
  122. #define SIG_SETMASK 0   /* set mask with sigprocmask() */
  123. #define SIG_BLOCK 1     /* set of signals to block */
  124. #define SIG_UNBLOCK 2   /* set of signals to, well, unblock */
  125.  
  126. /* These depend upon the type of sigset_t, which right now
  127.    is always a long.. They're in the POSIX namespace, but
  128.    are not ANSI. */
  129. #define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
  130. #define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
  131. #define sigemptyset(what)   (*(what) = 0, 0)
  132. #define sigfillset(what)    (*(what) = ~(0), 0)
  133. #define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
  134.  
  135. int _EXFUN(sigprocmask, (int how, const sigset_t *set, sigset_t *oset));
  136.  
  137. #if defined(_POSIX_THREADS)
  138. int _EXFUN(pthread_sigmask, (int how, const sigset_t *set, sigset_t *oset));
  139. #endif
  140.  
  141. /* protos for functions found in winsup sources for CYGWIN */
  142. #if defined(__CYGWIN__) || defined(__rtems__)
  143. #undef sigaddset
  144. #undef sigdelset
  145. #undef sigemptyset
  146. #undef sigfillset
  147. #undef sigismember
  148.  
  149. #ifdef _COMPILING_NEWLIB
  150. int _EXFUN(_kill, (pid_t, int));
  151. #endif
  152. int _EXFUN(kill, (pid_t, int));
  153. int _EXFUN(killpg, (pid_t, int));
  154. int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
  155. int _EXFUN(sigaddset, (sigset_t *, const int));
  156. int _EXFUN(sigdelset, (sigset_t *, const int));
  157. int _EXFUN(sigismember, (const sigset_t *, int));
  158. int _EXFUN(sigfillset, (sigset_t *));
  159. int _EXFUN(sigemptyset, (sigset_t *));
  160. int _EXFUN(sigpending, (sigset_t *));
  161. int _EXFUN(sigsuspend, (const sigset_t *));
  162. int _EXFUN(sigpause, (int));
  163.  
  164. #if defined(_POSIX_THREADS)
  165. #ifdef __CYGWIN__
  166. #  ifndef _CYGWIN_TYPES_H
  167. #    error You need the winsup sources or a cygwin installation to compile the cygwin version of newlib.
  168. #  endif
  169. #endif
  170. int _EXFUN(pthread_kill, (pthread_t thread, int sig));
  171. #endif
  172.  
  173. #if defined(_POSIX_REALTIME_SIGNALS)
  174.  
  175. /*  3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76
  176.     NOTE: P1003.1c/D10, p. 39 adds sigwait().  */
  177.  
  178. int _EXFUN(sigwaitinfo, (const sigset_t *set, siginfo_t *info));
  179. int _EXFUN(sigtimedwait,
  180.   (const sigset_t *set, siginfo_t *info, const struct timespec  *timeout)
  181. );
  182. int _EXFUN(sigwait, (const sigset_t *set, int *sig));
  183.  
  184. /*  3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */
  185. int _EXFUN(sigqueue, (pid_t pid, int signo, const union sigval value));
  186.  
  187. #endif /* defined(_POSIX_REALTIME_SIGNALS) */
  188.  
  189. #endif /* defined(__CYGWIN__) || defined(__rtems__) */
  190.  
  191. /* #endif __STRICT_ANSI__ */
  192.  
  193. #if defined(___AM29K__)
  194. /* These all need to be defined for ANSI C, but I don't think they are
  195.    meaningful.  */
  196. #define SIGABRT 1
  197. #define SIGFPE 1
  198. #define SIGILL 1
  199. #define SIGINT 1
  200. #define SIGSEGV 1
  201. #define SIGTERM 1
  202. /* These need to be defined for POSIX, and some others do too.  */
  203. #define SIGHUP 1
  204. #define SIGQUIT 1
  205. #define NSIG 2
  206. #elif defined(__GO32__)
  207. #define SIGINT  1
  208. #define SIGKILL 2
  209. #define SIGPIPE 3
  210. #define SIGFPE  4
  211. #define SIGHUP  5
  212. #define SIGTERM 6
  213. #define SIGSEGV 7
  214. #define SIGTSTP 8
  215. #define SIGQUIT 9
  216. #define SIGTRAP 10
  217. #define SIGILL  11
  218. #define SIGEMT  12
  219. #define SIGALRM 13
  220. #define SIGBUS  14
  221. #define SIGLOST 15
  222. #define SIGSTOP 16
  223. #define SIGABRT 17
  224. #define SIGUSR1 18
  225. #define SIGUSR2 19
  226. #define NSIG    20
  227. #elif !defined(SIGTRAP)
  228. #define SIGHUP  1       /* hangup */
  229. #define SIGINT  2       /* interrupt */
  230. #define SIGQUIT 3       /* quit */
  231. #define SIGILL  4       /* illegal instruction (not reset when caught) */
  232. #define SIGTRAP 5       /* trace trap (not reset when caught) */
  233. #define SIGIOT  6       /* IOT instruction */
  234. #define SIGABRT 6       /* used by abort, replace SIGIOT in the future */
  235. #define SIGEMT  7       /* EMT instruction */
  236. #define SIGFPE  8       /* floating point exception */
  237. #define SIGKILL 9       /* kill (cannot be caught or ignored) */
  238. #define SIGBUS  10      /* bus error */
  239. #define SIGSEGV 11      /* segmentation violation */
  240. #define SIGSYS  12      /* bad argument to system call */
  241. #define SIGPIPE 13      /* write on a pipe with no one to read it */
  242. #define SIGALRM 14      /* alarm clock */
  243. #define SIGTERM 15      /* software termination signal from kill */
  244.  
  245. #if defined(__rtems__)
  246. #define SIGURG  16      /* urgent condition on IO channel */
  247. #define SIGSTOP 17      /* sendable stop signal not from tty */
  248. #define SIGTSTP 18      /* stop signal from tty */
  249. #define SIGCONT 19      /* continue a stopped process */
  250. #define SIGCHLD 20      /* to parent on child stop or exit */
  251. #define SIGCLD  20      /* System V name for SIGCHLD */
  252. #define SIGTTIN 21      /* to readers pgrp upon background tty read */
  253. #define SIGTTOU 22      /* like TTIN for output if (tp->t_local&LTOSTOP) */
  254. #define SIGIO   23      /* input/output possible signal */
  255. #define SIGPOLL SIGIO   /* System V name for SIGIO */
  256. #define SIGWINCH 24     /* window changed */
  257. #define SIGUSR1 25      /* user defined signal 1 */
  258. #define SIGUSR2 26      /* user defined signal 2 */
  259.  
  260. /* Real-Time Signals Range, P1003.1b-1993, p. 61
  261.    NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX
  262.          (which is a minimum of 8) signals.
  263.  */
  264. #define SIGRTMIN 27
  265. #define SIGRTMAX 31
  266. #define __SIGFIRSTNOTRT SIGHUP
  267. #define __SIGLASTNOTRT  SIGUSR2
  268.  
  269. #define NSIG    32      /* signal 0 implied */
  270.  
  271. #elif defined(__svr4__)
  272. /* svr4 specifics. different signals above 15, and sigaction. */
  273. #define SIGUSR1 16
  274. #define SIGUSR2 17
  275. #define SIGCLD  18
  276. #define SIGPWR  19
  277. #define SIGWINCH 20
  278. #define SIGPOLL 22      /* 20 for x.out binaries!!!! */
  279. #define SIGSTOP 23      /* sendable stop signal not from tty */
  280. #define SIGTSTP 24      /* stop signal from tty */
  281. #define SIGCONT 25      /* continue a stopped process */
  282. #define SIGTTIN 26      /* to readers pgrp upon background tty read */
  283. #define SIGTTOU 27      /* like TTIN for output if (tp->t_local&LTOSTOP) */
  284. #define NSIG    28     
  285. #else
  286. #define SIGURG  16      /* urgent condition on IO channel */
  287. #define SIGSTOP 17      /* sendable stop signal not from tty */
  288. #define SIGTSTP 18      /* stop signal from tty */
  289. #define SIGCONT 19      /* continue a stopped process */
  290. #define SIGCHLD 20      /* to parent on child stop or exit */
  291. #define SIGCLD  20      /* System V name for SIGCHLD */
  292. #define SIGTTIN 21      /* to readers pgrp upon background tty read */
  293. #define SIGTTOU 22      /* like TTIN for output if (tp->t_local&LTOSTOP) */
  294. #define SIGIO   23      /* input/output possible signal */
  295. #define SIGPOLL SIGIO   /* System V name for SIGIO */
  296. #define SIGXCPU 24      /* exceeded CPU time limit */
  297. #define SIGXFSZ 25      /* exceeded file size limit */
  298. #define SIGVTALRM 26    /* virtual time alarm */
  299. #define SIGPROF 27      /* profiling time alarm */
  300. #define SIGWINCH 28     /* window changed */
  301. #define SIGLOST 29      /* resource lost (eg, record-lock lost) */
  302. #define SIGUSR1 30      /* user defined signal 1 */
  303. #define SIGUSR2 31      /* user defined signal 2 */
  304. #define NSIG    32      /* signal 0 implied */
  305. #endif
  306. #endif
  307.  
  308. #ifdef __cplusplus
  309. }
  310. #endif
  311.  
  312. #ifndef _SIGNAL_H_
  313. /* Some applications take advantage of the fact that <sys/signal.h>
  314.  * and <signal.h> are equivalent in glibc.  Allow for that here.  */
  315. #include <signal.h>
  316. #endif
  317. #endif /* _SYS_SIGNAL_H */
  318.