signal.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #pragma once
  27. #include <signal_numbers.h>
  28. #include <sys/types.h>
  29. __BEGIN_DECLS
  30. typedef void (*__sighandler_t)(int);
  31. typedef __sighandler_t sighandler_t;
  32. typedef uint32_t sigset_t;
  33. typedef uint32_t sig_atomic_t;
  34. union sigval {
  35. int sival_int;
  36. void* sival_ptr;
  37. };
  38. typedef struct siginfo {
  39. int si_signo;
  40. int si_code;
  41. pid_t si_pid;
  42. uid_t si_uid;
  43. void* si_addr;
  44. int si_status;
  45. union sigval si_value;
  46. } siginfo_t;
  47. struct sigaction {
  48. union {
  49. void (*sa_handler)(int);
  50. void (*sa_sigaction)(int, siginfo_t*, void*);
  51. };
  52. sigset_t sa_mask;
  53. int sa_flags;
  54. };
  55. int kill(pid_t, int sig);
  56. int killpg(int pgrp, int sig);
  57. sighandler_t signal(int sig, sighandler_t);
  58. int pthread_sigmask(int how, const sigset_t* set, sigset_t* ol_dset);
  59. int sigaction(int sig, const struct sigaction* act, struct sigaction* old_act);
  60. int sigemptyset(sigset_t*);
  61. int sigfillset(sigset_t*);
  62. int sigaddset(sigset_t*, int sig);
  63. int sigdelset(sigset_t*, int sig);
  64. int sigismember(const sigset_t*, int sig);
  65. int sigprocmask(int how, const sigset_t* set, sigset_t* old_set);
  66. int sigpending(sigset_t*);
  67. int sigsuspend(const sigset_t*);
  68. int raise(int sig);
  69. int getsignalbyname(const char*);
  70. extern const char* sys_siglist[NSIG];
  71. #define SIG_DFL ((__sighandler_t)0)
  72. #define SIG_ERR ((__sighandler_t)-1)
  73. #define SIG_IGN ((__sighandler_t)1)
  74. #define SA_NOCLDSTOP 1
  75. #define SA_NOCLDWAIT 2
  76. #define SA_SIGINFO 4
  77. #define SA_ONSTACK 0x08000000
  78. #define SA_RESTART 0x10000000
  79. #define SA_NODEFER 0x40000000
  80. #define SA_RESETHAND 0x80000000
  81. #define SA_NOMASK SA_NODEFER
  82. #define SA_ONESHOT SA_RESETHAND
  83. #define SIG_BLOCK 0
  84. #define SIG_UNBLOCK 1
  85. #define SIG_SETMASK 2
  86. #define CLD_EXITED 0
  87. #define CLD_KILLED 1
  88. #define CLD_DUMPED 2
  89. #define CLD_TRAPPED 3
  90. #define CLD_STOPPED 4
  91. #define CLD_CONTINUED 5
  92. __END_DECLS