Subversion Repositories Kolibri OS

Rev

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