sigaction

å称
     sigaction — ã½ããã¦ã§ã¢ã·ã°ãã«æ©è½

ã©ã¤ãã©ãª
     Standard C Library (libc, -lc)

æ¸å¼
     <signal.h>

     struct  sigaction {
             union {
                     void    (*__sa_handler)(int);
                     void    (*__sa_sigaction)(int, struct __siginfo *, void *);
             } __sigaction_u;                /* ã·ã°ãã«ãã³ãã© */
             int     sa_flags;               /* å¾è¿°ã®ã·ã°ãã«ãªãã·ã§ã³åç§ */
             sigset_t sa_mask;               /* é©ç¨ããã·ã°ãã«ãã¹ã¯ */
     };

     #define sa_handler      __sigaction_u.__sa_handler
     #define sa_sigaction    __sigaction_u.__sa_sigaction
     int sigaction(int sig, const struct sigaction * restrict act,
     struct sigaction * restrict oact)

解説
     ã·ã¹ãã ã§ã¯ã·ã°ãã«ã®éåãå®ç¾©ãã¦ããã ãããã¯ããã»ã¹ã«éä¿¡ããããã¨ãããã¾ãã
     ã·ã°ãã«ã®éä¿¡ã¯ããã¼ãã¦ã§ã¢å²è¾¼ã¿ã®çºçã«ä¼¼ã¦ãã¾ãã
     é常ã®å ´åãã·ã°ãã«ã®ãããªãçºçã¯ãããã¯ããã ç¾å¨ã®ããã»ã¹ã³ã³ããã¹ãã¯ä¿å‐
     ããã¦ãæ°ããããã»ã¹ã³ã³ããã¹ãã ä½æããã¾ãã ããã»ã¹ã¯ãã·ã°ãã«ã®éä¿¡å handler
     ãæå®ãããã¨ãããã°ãã·ã°ãã«ã ç¡è¦ ãããã¨ãæå®ãããã¨ãããã¾ãã
     ã·ã°ãã«ãçºçããå ´åã«ãã·ã¹ãã ãããã©ã«ãã®ã¢ã¯ã·ã§ã³ãåããã¨ã æå®ãããã¨ãå¯è½ã§ãã
     ã·ã°ãã«ã ããã㯠ããããã¨ãããããã®å ´åãã·ã°ãã«ã®éä¿¡ã¯ã ãããã¯ã解é¤
     ãããã¾ã§å»¶æããã¾ãã éä¿¡æã«åãã¢ã¯ã·ã§ã³ã¯ãéä¿¡æã«æ±ºã¾ãã¾ãã
     é常ã®å ´åã¯ãã·ã°ãã«ãã³ãã©ããããã»ã¹ã®ç¾è¡ã¹ã¿ãã¯ã§åä½ãã¾ãã
     ããã¯ãã³ãã©ãã¨ã«å¤æ´å¯è½ã§ãããå¤æ´ããã°ãã·ã°ãã«ã¯ç¹æ®ãª ã·ã°ãã«ã¹ã¿ãã¯
     ã§å®è¡å¯è½ã§ãã

     é常ã®å ´åãã·ã°ãã«ã«ã¼ãã³ã¯ãå¼ã³åºãã®åå ã¨ãªã£ãã·ã°ãã«ã ãããã¯ããã
     ç¶æã§åä½ãã¾ããããã®ä»ã®ã·ã°ãã«ãçºçããå¯è½æ§ã¯ ããã¾ãã ã°ãã¼ãã«ã® ã·ã°ãã«ãã¹ã¯
     ã«ã¯ãããã»ã¹ã¸ã®éä¿¡ãç¾å¨ ãããã¯ããã¦ããã·ã°ãã«ã®éåãå®ç¾©ããã¦ãã¾ãã ãã‐
     ã»ã¹ã®ã·ã°ãã«ãã¹ã¯ã¯ã親ã®ã·ã°ãã«ãã¹ã¯ã§åæåããã¾ã (é常ã¯ç©º)ã
     sigprocmask(2) ãå¼ã³åºãããå ´åãã¾ãã¯ã·ã°ãã«ãããã»ã¹ã«éä¿¡ãããå ´åã«ã
     ã·ã°ãã«ãã¹ã¯ã¯å¤æ´ããã¾ãã

     ããã·ã°ãã«ã®çèµ·æ¡ä»¶ãããã»ã¹ã§çºçããã¨ããã®ã·ã°ãã«ãã ããã»ã¹ã§ä¿çä¸‐
     ã®ã·ã°ãã«ã®éåã«è¿½å ããã¾ãã ãã®ã·ã°ãã«ãããã»ã¹ã§ç¾å¨ ãããã¯
     ããã¦ããªãå ´åã¯ãããã»ã¹ã«éä¿¡ããã¾ãã ã·ã°ãã«ã¯ããã‐
     ã»ã¹ããªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ã«å¥ã£ã¦ããéã«
     (ã·ã¹ãã å¼ã³åºãããã¼ã¸ã¨ã©ã¼ããã©ãããã¯ããã¯å²è¾¼ã¿ä¸ãªã©ã«) éä¿¡ããã¾ãã
     è¤æ°ã®ã·ã°ãã«ã®éä¿¡æºåãåæã«æ´ã£ãå ´åã¯ããã©ããã§çããã·ã°ãã«ã åã«éä¿¡ããã¾ãã
     ãã®ä»ã®ã·ã°ãã«ã¯ããããããåã®ã·ã°ãã«ã®ãã³ãã©ã«å¯¾ãã
     æåã®å½ä»¤ã®åã«å²ãè¾¼ãã ç¶æã§åæã«å¦çããã¾ãã ä¿çã«ãªã£ã¦ããã·ã°ãã«ã®éåã¯ã
     sigpending(2) ã·ã¹ãã ã³ã¼ã«ã§è¿ããã¾ãã ææãããã·ã°ãã«ãéä¿¡ãããã¨ããã‐
     ã»ã¹ã®ç¾å¨ã® ç¶æãä¿åãããæ°ããã·ã°ãã«ãã¹ã¯ã以ä¸ã§èª¬æããããã«ç®åºããã¦ã
     ã·ã°ãã«ãã³ãã©ãå¼ã³åºããã¾ãã ãã³ãã©ã®å¼ã³åºãã¯ã ã·ã°ãã«å¦çã«ã¼ãã³ãæ‐
     £å¸¸ã«æ»ã£ãå ´åã«ãããã»ã¹ãã·ã°ãã«éä¿¡åã® ã³ã³ããã¹ãã§å®è¡ãåéããããã«è¨‐
     å®ããã¾ãã ããã»ã¹ãå¥ã®ã³ã³ããã¹ãã§ã®åéãæãå ´åã¯ã åã®ã³ã³ãã‐
     ã¹ããã®ãã®ãèªåèªèº«ã§å復ããããã«è¨å®ããå¿è¦ãããã¾ãã

     ã·ã°ãã«ãããã»ã¹ã«éä¿¡ãããã¨ãããã»ã¹ã® ã·ã°ãã«ãã³ãã©ã®å®è¡ãç¶ãé (ã¾ãã¯
     sigprocmask(2) ã·ã¹ãã ã³ã¼ã«ãå¼ã³åºãããã¾ã§)ãæ°ããã·ã°ãã«ãã¹ã¯ãè¨ç½®ããã¾ãã
     ãã®ãã¹ã¯ã¯ãç¾å¨ã®ã·ã°ãã«ãã¹ã¯éåãéä¿¡ãããã·ã°ãã«ã
     å¼ã³åºããããã³ãã©ã«é¢é£ããã·ã°ãã«ãã¹ã¯ã®åéåãåã£ã¦å½¢æããã¾ãã

     sigaction() ã·ã¹ãã ã³ã¼ã«ã¯ã sig ã§æå®ããã·ã°ãã«ã®ã¢ã¯ã·ã§ã³ãå²ãå½ã¦ã¾ãã
     act ã 0 ã§ãªãå ´åã¯ãã¢ã¯ã·ã§ã³ (SIG_DFL, SIG_IGN
     ããã³ãã©ã«ã¼ãã³)ãããã³æå®ãããã·ã°ãã«ã®éä¿¡æ㫠使ç¨ãããã¹ã¯ãæå®ããã¾ãã oact ã
     0 ã§ãªãå ´åã¯ããã®ã·ã°ãã«ã®ããã¾ã§ã®å¦çæå ±ãã¦ã¼ã¶ã«è¿ããã¾ãã

     ã·ã°ãã«ãã³ãã©ãè¨ç½®ãããã¨ãé常ã®å ´åã¯å¥ã® sigaction()
     ã·ã¹ãã ã³ã¼ã«ãå¼ã³åºãã execve(2) ãå®è¡ããã¾ã§ããã®ã·ã°ãã«ãã³ãã©ã¯è¨‐
     ç½®ãããã¾ã¾ã§ãã sa_handler ã SIG_DFL ã«è¨å®ãããã¨ã§ã
     ã·ã°ãã«ãã¨ã«åºæãªããã©ã«ãã¢ã¯ã·ã§ã³ã«ãªã»ãããããã¨ãã§ãã¾ãã ããã©ã«ãã¨ã¯ããã‐
     ã»ã¹ã®çµäº (ã³ã¢ãã³ããåããããã¨ãããã¾ã)ã ã¢ã¯ã·ã§ã³ãªããããã»ã¹ã®åæ¢ããã‐
     ã»ã¹ã®ç¶ç¶ã§ãã ããããã®ã·ã°ãã«ã®ããã©ã«ãã¢ã¯ã·ã§ã³ã«ã¤ãã¦ã¯ã
     ä¸è¨ã®ã·ã°ãã«ãªã¹ããåç§ãã¦ãã ããã sa_handler ã SIG_DFL
     ã§ããå ´åãã·ã°ãã«ã®ããã©ã«ãã¢ã¯ã·ã§ã³ã¯ã·ã°ãã«ã®ç ´æ£ã«ãªãã¾ãã
     ã¾ããã·ã°ãã«ãä¿çã«ãªã£ã¦ããå ´åã§ããã·ã°ãã«ããã¹ã¯ããã¦ãã¦ã ä¿çä¸‐
     ã®ã·ã°ãã«ã¯ç ´æ£ããã¾ãã sa_handler ã SIG_IGN ã«è¨‐
     å®ããã¨ãç¾å¨ã®ã·ã°ãã«å®ä½ã¨ä¿çä¸ã®ã·ã°ãã«å®ä½ã¯ç¡è¦ããã¦ ç ´æ£ããã¾ãã

     ãªãã·ã§ã³ã¯ã sa_flags ãè¨å®ãããã¨ã§æå®ã§ãã¾ãã
     ããããã®ãããã®æå³ã¯ä»¥ä¸ã®ã¨ããã§ã:

           SA_NOCLDSTOP    SIGCHLD ã·ã°ãã«ã®åä¿¡é¢æ°ãè¨ç½®ããå ´åã«ãã®ããããè¨‐
                           å®ããã¨ã åããã»ã¹ãåæ¢ããã¨ãã§ã¯ãªããåãã‐
                           ã»ã¹ãçµäºããã¨ãã«ã®ã¿ã SIGCHLD ã·ã°ãã«ãçæããã¾ãã

           SA_NOCLDWAIT    SIGCHLD ã·ã°ãã«ã§ sigaction()
                           ãå¼ã³åºãå ´åã«ãã®ããããè¨‐
                           å®ããã¨ãã·ã¹ãã ã¯ãå¼ã³åºãå´ããã»ã¹ã® åãã‐
                           ã»ã¹ãçµäºããã¨ãã«ã¾ã³ãããã»ã¹ãä½æããªããªãã¾ãã
                           ãã®ãã¨ãå¼ã³åºãå´ããã»ã¹ã wait(2) (ãããã«ç¸å½ããé¢æ°)
                           ãå®è¡ããã¨ãå¼ã³åºãå´ããã»ã¹ã®ãã¹ã¦ ã®åãã‐
                           ã»ã¹ãçµäºããã¾ã§ãããã¯ãã次㫠errno ã ECHILD ã«è¨‐
                           å®ã㦠-1 ãè¿ãã¾ãã SIGCHLD ã®ããã® sa_handler ã«
                           SIG_IGN ãè¨å®ãããã¨ã«ãã£ã¦ã
                           ã¾ã³ãã®ä½æãé¿ããåãå¹æãå¾ããã¨ãå¯è½ã§ãã

           SA_ONSTACK      ãã®ããããè¨å®ããã¨ãã·ã¹ãã ã¯ã sigaltstack(2) ã§æå®ããã
                           ã·ã°ãã«ã¹ã¿ã㯠ã®ä¸ã§ãããã»ã¹ã«ã·ã°ãã«ãéä¿¡ãã¾ãã

           SA_NODEFER      ãã®ããããè¨å®ããã¨ãéä¿¡æ¸ã¿ã·ã°ãã«ã®ãããªãçºçãã
                           ãã³ãã©ã®å®è¡ä¸ã«ãã¹ã¯ãããªããªãã¾ãã

           SA_RESETHAND    ãã®ããããè¨å®ããã¨ãã·ã°ãã«ãéä¿¡ãããç¬éã«ããã³ãã©ã
                           SIG_DFL ã«ãªã»ããããã¾ãã

           SA_RESTART      ä¸ã®æ®µè½ãåç§ãã¦ãã ããã

           SA_SIGINFO      ãã®ããããè¨å®ããã¦ããå ´åããã³ãã©é¢æ°ã¯ã struct
                           sigaction æ§é ä½ã® sa_sigaction
                           ã¡ã³ããæããã®ã¨è¦ãªãã¾ãã ãã³ãã©é¢æ°ã¯ãåã«ç¤ºãããã‐
                           ãã¿ã¤ããããã¯å¾ã§ç¤ºã 使ç¨ä¾ ã«ä¸è´ããªãã¦ã¯ãªãã¾ããã
                           ãã®ãããã¯ã SIG_DFL ããã㯠SIG_IGN ãå²ãå½ã¦ãæã«ã¯è¨‐
                           å®ãã¦ã¯ããã¾ããã

     次ã«æããã·ã¹ãã ã³ã¼ã«ã®å®è¡ä¸ã«ã·ã°ãã«ãææãããã¨ã
     ãã®ã·ã¹ãã ã³ã¼ã«ã®å¼ã³åºãã¯ã ã¨ã©ã¼ EINTR ã§å¼·å¶çµäºãããããè¦æ±ããç‐
     ããã¼ã¿è»¢éã§æ»ãããã¾ãã¯åéããã¾ãã ä¿çä¸ã®ã·ã¹ãã ã³ã¼ã«ã®åéã¯ã sa_flags ã§
     SA_RESTART ããããè¨å®ãããã¨ã§è¦æ±ã§ãã¾ãã å½±é¿ãåããã·ã¹ãã ã³ã¼ã«ã¯ã
     éä¿¡ãã£ãã«ãéãããã¤ã¹ (端æ«ãªã©ãé常ãã¡ã¤ã«ã§ã¯ãªããã®) ã«å¯¾ãã open(2),
     read(2), write(2), sendto(2), recvfrom(2), sendmsg(2), recvmsg(2) ã¨
     wait(2), ioctl(2) ã§ãã ãããããã§ã«å®è¡ããã¦ããã·ã¹ãã ã³ã¼ã«ã¯åéãããã
     é¨åçãªå¦çæåã®çµæ (çãèªåãã«ã¦ã³ããªã©) ãè¿ãã¾ãã

     fork(2) ã vfork(2) ã®å¾ã§ã¯ããã¹ã¦ã®ã·ã°ãã«ãã·ã°ãã«ãã¹ã¯ãã·ã°ãã«ã¹ã¿ãã¯ã
     åéãã©ã°ãå²è¾¼ã¿ãã©ã°ãåããã»ã¹ã«ç¶æ¿ããã¾ãã

     execve(2) ã·ã¹ãã ã³ã¼ã«ã¯ãææããã¦ãããã¹ã¦ã®ã·ã°ãã«ã®ããã©ã«ãã¢ã¯ã·ã§ã³ã
     åã«æ»ãããã¹ã¦ã®ã·ã°ãã«ãã¦ã¼ã¶ã¹ã¿ãã¯ã§åä¿¡ãããããã«ãªã»ãããã¾ãã
     ç¡è¦ãããã·ã°ãã«ã¯ç¡è¦ãããã¾ã¾ã§ãã ã·ã°ãã«ãã¹ã¯ã¯åãç¶æã®ã¾ã¾ã§ãã ä¿çä¸‐
     ã®ã·ã¹ãã ã³ã¼ã«ãåéããè¨å®ã®ã·ã°ãã«ã¯ããã®åéã®è¨å®ã®ã¾ã¾ã§ãã

     以ä¸ã¯ãã¹ã¦ã®ã·ã°ãã«ã®ãªã¹ãã§ãã å称ã¯ãã¤ã³ã¯ã«ã¼ããã¡ã¤ã« <signal.h>
     ã«ãããã®ã¨åãã§ã:

     å称            ããã©ã«ãã¢ã¯ã·ã§ã³       説æ
     SIGHUP          ããã»ã¹ã®çµäº            端æ«ã©ã¤ã³ã®ãã³ã°ã¢ãã
     SIGINT          ããã»ã¹ã®çµäº            ããã°ã©ã ã®å²è¾¼ã¿
     SIGQUIT         ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       ããã°ã©ã ã®ä¸æçµäº
     SIGILL          ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       ä¸æ£ãªå½ä»¤
     SIGTRAP         ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       ãã©ããã®ãã¬ã¼ã¹
     SIGABRT         ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       abort(3) ã®å¼ã³åºã (以åã®
                                             SIGIOT)
     SIGEMT          ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       å½ä»¤å®è¡ã®ã¨ãã¥ã¬ã¼ã
     SIGFPE          ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       æµ®åå°æ°ä¾å¤
     SIGKILL         ããã»ã¹ã®çµäº            ããã°ã©ã ã®å¼·å¶çµäº
     SIGBUS          ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       ãã¹ã¨ã©ã¼
     SIGSEGV         ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       ã»ã°ã¡ã³ãã¼ã·ã§ã³éå
     SIGSYS          ã³ã¢ã¤ã¡ã¼ã¸ã®ä½æ       åå¨ããªãã·ã¹ãã ã³ã¼ã«ã®å¼ã³åºã
     SIGPIPE         ããã»ã¹ã®çµäº            èªåãå´ããªããã¤ãã¸ã®æ¸è¾¼ã¿
     SIGALRM         ããã»ã¹ã®çµäº            ãªã¢ã«ã¿ã¤ã ã¿ã¤ãã®æºäº
     SIGTERM         ããã»ã¹ã®çµäº            ã½ããã¦ã§ã¢çµäºã·ã°ãã«
     SIGURG          ã·ã°ãã«ã®ç ´æ£          ç·æ¥ç¶æ³ãã½ã±ããã«çºç
     SIGSTOP         ããã»ã¹ã®åæ¢             åæ¢ (ææãç¡è¦ãã§ãã¾ãã)
     SIGTSTP         ããã»ã¹ã®åæ¢             ãã¼ãã¼ãããçæãããåæ¢ã·ã°ãã«
     SIGCONT         ã·ã°ãã«ã®ç ´æ£          åæ¢å¾ã®ç¶ç¶
     SIGCHLD         ã·ã°ãã«ã®ç ´æ£          åããã»ã¹ã®ç¶æå¤å
     SIGTTIN         ããã»ã¹ã®åæ¢             ããã¯ã°ã©ã¦ã³ããã‐
                                             ã»ã¹ãå¶å¾¡ç«¯æ«ããèªã¿åããã¨ãã
     SIGTTOU         ããã»ã¹ã®åæ¢             ããã¯ã°ã©ã¦ã³ããã‐
                                             ã»ã¹ãå¶å¾¡ç«¯æ«ã«æ¸ãè¾¼ããã¨ãã
     SIGIO           ã·ã°ãã«ã®ç ´æ£          è¨è¿°åã¸ã® I/O å¯è½ (fcntl(2)
                                             åç§)
     SIGXCPU         ããã»ã¹ã®çµäº            cpu å¶éæéã®è¶é (setrlimit(2) åç§)
     SIGXFSZ         ããã»ã¹ã®çµäº            ãã¡ã¤ã«ãµã¤ãºå¶éã®è¶é
                                             (setrlimit(2) åç§)
     SIGVTALRM       ããã»ã¹ã®çµäº            ä»®æ³æéã¢ã©ã¼ã  (setitimer(2)
                                             åç§)
     SIGPROF         ããã»ã¹ã®çµäº            ãããã¡ã¤ãªã³ã°ã¿ã¤ãã¢ã©ã¼ã
                                             (setitimer(2) åç§)
     SIGWINCH        ã·ã°ãã«ã®ç ´æ£          ã¦ã£ã³ãã¦ãµã¤ãºã®å¤å
     SIGINFO         ã·ã°ãã«ã®ç ´æ£          ãã¼ãã¼ãããã®ã¹ãã¼ã¿ã¹è¦æ±
     SIGUSR1         ããã»ã¹ã®çµäº            ã¦ã¼ã¶å®ç¾©ã·ã°ãã« 1
     SIGUSR2         ããã»ã¹ã®çµäº            ã¦ã¼ã¶å®ç¾©ã·ã°ãã« 2

注
     act ã«æå®ãã sa_mask ãã£ã¼ã«ãã§ã¯ã SIGKILL ã SIGSTOP ããããã¯ã§ãã¾ããã ãã‐
     ãã¯ãããã¨ãã¦ãç¡è¦ããã¾ãã

     以ä¸ã®é¢æ°ã¯ãåå¥çã§ãããã·ã°ãã«ã§å²ãè¾¼ã¾ãããã¨ããªããã®ã©ã¡ããã§ã
     éåæã·ã°ãã«ã§ãå®å¨ã§ãã
     ãã®ãããã¢ããªã±ã¼ã·ã§ã³ã¯ãã·ã°ãã«åä¿¡é¢æ°ããå¶éãªãå¼ã³åºãã¾ã:

     ãã¼ã¹ã¤ã³ã¿ãã§ã¼ã¹

     _exit(), access(), alarm(), cfgetispeed(), cfgetospeed(), cfsetispeed(),
     cfsetospeed(), chdir(), chmod(), chown(), close(), creat(), dup(),
     dup2(), execle(), execve(), fcntl(), fork(), fpathconf(), fstat(),
     fsync(), getegid(), geteuid(), getgid(), getgroups(), getpgrp(),
     getpid(), getppid(), getuid(), kill(), link(), lseek(), mkdir(),
     mkfifo(), open(), pathconf(), pause(), pipe(), raise(), read(), rename(),
     rmdir(), setgid(), setpgid(), setsid(), setuid(), sigaction(),
     sigaddset(), sigdelset(), sigemptyset(), sigfillset(), sigismember(),
     signal(), sigpending(), sigprocmask(), sigsuspend(), sleep(), stat(),
     sysconf(), tcdrain(), tcflow(), tcflush(), tcgetattr(), tcgetpgrp(),
     tcsendbreak(), tcsetattr(), tcsetpgrp(), time(), times(), umask(),
     uname(), unlink(), utime(), wait(), waitpid(), write()

     ãªã¢ã«ã¿ã¤ã ã¤ã³ã¿ãã§ã¼ã¹

     aio_error(), clock_gettime(), sigpause(), timer_getoverrun(),
     aio_return(), fdatasync(), sigqueue(), timer_gettime(), aio_suspend(),
     sem_post(), sigset(), timer_settime()

     ANSI C ã¤ã³ã¿ãã§ã¼ã¹

     strcpy(), strcat(), strncpy(), strncat() ããã¦å¤åä»ã«ãããã¤ã

     æ¡å¼µã¤ã³ã¿ãã§ã¼ã¹

     strlcpy(), strlcat()

     ä¸ã®ãªã¹ãã«è¨è¼ããã¦ããªããã¹ã¦ã®é¢æ°ã¯ãã·ã°ãã«ã«é¢ãã¦å®å¨ã§ãªã ã¨èãããã¾ãã
     ã¤ã¾ãããã®ãããªé¢æ°ãã·ã°ãã«ãã³ãã©ããå¼ã³åºãããã¨ãã®åä½ã¯ã æªå®ç¾©ã§ãã
     ãããä¸è¬çã«ãã·ã°ãã«ãã³ãã©ã¯ãã©ã°ãè¨å®ãã以ä¸ã®ãã¨ã¯
     ãã¾ãããã¹ãã§ã¯ãªãããã以å¤ã®ã¢ã¯ã·ã§ã³ã¯å®å¨ã§ã¯ããã¾ããã

     ã¾ãã大åå¤æ° errno ã®ã³ãã¼ãä½æããã·ã°ãã«ãã³ãã©ããæ»ãåã«ãã®å¤ãæ»ãããã«
     ããã®ã¯ãããã¨ã§ãã ãããããã¨ã«ãã£ã¦ãã·ã°ãã«ãã³ãã©ã®åé¨ããå¼ã°ããé¢æ°ã«ãã£ã¦
     errno ãè¨å®ããã¦ãã¾ãã¨ããå¯ä½ç¨ãé²ããã¨ãã§ãã¾ãã

æ»ãå¤
     The sigaction() function returns the value 0 if successful; otherwise the
     value -1 is returned and the global variable errno is set to indicate the
     error.

使ç¨ä¾
     ãã³ãã©ãä¸è´ããå¯è½æ§ã®ãããããã¿ã¤ã㯠3 ã¤ããã¾ã:

           ANSI C:
                  void handler(int);

           ä¼çµ±ç㪠BSD ã¹ã¿ã¤ã«:
                  void handler(int, int code, struct sigcontext *scp);

           POSIX ã® SA_SIGINFO:
                  void handler(int, siginfo_t *info, ucontext_t *uap);

     sa_flags ãã©ã°ä¸ã§ SA_SIGINFO ããããè¨å®ããã¦ããå ´åããã³ãã©é¢æ°ã¯ SA_SIGINFO
     ãããã¿ã¤ãã«ä¸è´ããªãã¦ã¯ãªãã¾ããã ãã®å ´åã struct sigaction æ§é ä½ã®
     sa_sigaction ã¡ã³ãããã³ãã©é¢æ°ãæãã¦ããªããã°ãªãã¾ããã ãã®æ¹æ³ã§ SIG_DFL ãããã¯
     SIG_IGN ãå²ãå½ã¦ã¦ã¯ãããªããã¨ã«æ³¨æãã¦ãã ããã

     SA_SIGINFO ãã©ã°ãè¨å®ããã¦ããªãå ´åããã³ãã©é¢æ°ã¯ ANSI C ãããã¯ä¼çµ±ç㪠BSD
     ãããã¿ã¤ãã®ã©ã¡ããã«ä¸è´ããªãã¦ã¯ãªããã struct sigaction æ§é ä½ã® sa_handler
     ã¡ã³ãããã³ãã©é¢æ°ãæãã¦ããªããã°ãªãã¾ããã å®éã«ã¯ã FreeBSD ã¯å¸¸ã«å¾èã§ãã BSD
     ãããã¿ã¤ãã® 3 ã¤ã®å¼æ°ãéãã¾ããã ANSI C ãã‐
     ãã¿ã¤ãã¯ãã®ãµãã»ããã«ãªã£ã¦ãã¾ãã®ã§ãã©ã¡ãã§ãåä½ãã¾ãã FreeBSD
     ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã® sa_handler ã¡ã³ã宣è¨ã¯ã (POSIX ã®è¦æ±ã«å¾ã) ANSI C
     ã®ãã®ã§ãã ãã®ããã BSD ã¹ã¿ã¤ã«ã®é¢æ°ã®ãã¤ã³ã¿ã®å ´åãè¦åã¡ãã»ã¼ã¸ãç¡ããã¦
     ã³ã³ãã¤ã«ããã«ã¯ãã£ã¹ãããå¿è¦ãããã¾ãã ä¼çµ±ç㪠BSD
     ã¹ã¿ã¤ã«ã¯ç§»æ¤æ§ããªãããã®æ©è½æ§ã SA_SIGINFO
     ãã³ãã©ã®å®å¨ãªé¨åéåã«ãªã£ã¦ãã¾ãã®ã§ã BSD
     ã¹ã¿ã¤ã«ã使ããã¨ã¯æ¨å¥¨ããã¦ãã¾ããã

     sig å¼æ°ã¯ã·ã°ãã«çªå·ã§ã <signal.h> ã® SIG... å¤ã®ãã¡ã® 1 ã¤ã§ãã

     BSD ã¹ã¿ã¤ã«ã®ãã³ãã©ã® code å¼æ°ããã³ SA_SIGINFO ãã³ãã©ã¸ã® info å¼æ°ã®
     si_code ã¡ã³ãã«ã¯ãã·ã°ãã«ã®çºççç±ã説æããæ°å¤ã³ã¼ããå«ã¾ãã¦ãã¾ãã
     é常ããã®æ°å¤ã³ã¼ã㯠<sys/signal.h> ã«ãã SI_... å¤ã® 1
     ã¤ã§ãããããããã¯ã·ã°ãã«ã«ç¹åããã³ã¼ããããªãã¡ SIGFPE ã«å¯¾ãã FPE_... å¤ã§ãã

     BSD ã¹ã¿ã¤ã«ã®ãã³ãã©ã® scp å¼æ°ã¯ struct sigcontext
     æ§é ä½ã®ã¤ã³ã¹ã¿ã³ã¹ãæãã¦ãã¾ãã

     POSIX SA_SIGINFO ãã³ãã©ã® uap å¼æ°ã¯ãucontext_t ã®ã¤ã³ã¹ã¿ã³ã¹ãæãã¦ãã¾ãã

ã¨ã©ã¼
     以ä¸ã®ãã¡ 1 ã¤ãçºçããã¨ã sigaction()
     ã·ã¹ãã ã³ã¼ã«ã¯ã¨ã©ã¼ã«ãªããæ°ããã·ã°ãã«ãã³ãã©ã¯è¨ç½®ããã¾ãã:

     [EFAULT]           act ã oact ã¯ããã‐
                        ã»ã¹ã«å²ãå½ã¦ãããã¢ãã¬ã¹ç©ºéã®ç¯å²å¤ãæãã¦ãã¾ãã

     [EINVAL]           sig å¼æ°ããæ£ããã·ã°ãã«çªå·ã«ãªã£ã¦ãã¾ããã

     [EINVAL]           SIGKILL ã SIGSTOP ã®ãã³ãã©ãç¡è¦ãããæä¾ãããã¨ãã¾ããã

è¦æ ¼
     sigaction() ã·ã¹ãã ã³ã¼ã«ã¯ã ISO/IEC 9945-1:1990 (“POSIX.1”)
     ã«é©åãã¦ãã¾ãã SA_ONSTACK ãã©ã°ã¨ SA_RESTART ãã©ã°ã¯ãBerkeley
     ã®æ¡å¼µæ©è½ã§ãã SIGTRAP, SIGEMT, SIGBUS, SIGSYS, SIGURG, SIGIO, SIGXCPU,
     SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGINFO ã·ã°ãã«ãåæ§ã§ãã
     ãããã®ã·ã°ãã«ã¯ã BSD ããæ´¾çããã·ã¹ãã ã®ã»ã¨ãã©ã§ä½¿ç¨ã§ãã¾ãã SA_NODEFER
     ãã©ã°ã¨ SA_RESETHAND
     ãã©ã°ã¯ããã®ä»ã®ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ã¨ã®ä¸ä½äºææ§ãä¿ã¤ããã®ãã®ã§ãã
     SA_NOCLDSTOP ãã©ã°ã¨ SA_NOCLDWAIT
     ãã©ã°ã¯ããã®ä»ã®ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ã§ä¸è¬çã«è¦ããããªãã·ã§ã³ã§ãã
     ãããã®ãã©ã°ã¯ SIGCHLD ãç¡è¦ãããã¨ã«ãã£ã¦ã¾ã³ãã®ä½æãé¿ãããªãã·ã§ã³ã¨ä¸ç·ã«ã
     Version 2 of the Single UNIX Specification (“SUSv2”) ã«ãã£ã¦æ¿èªããã¾ããã

é¢é£é ç®
     kill(1), kill(2), ptrace(2), sigaltstack(2), sigblock(2), sigpause(2),
     sigpending(2), sigprocmask(2), sigsetmask(2), sigsuspend(2), sigvec(2),
     wait(2), fpsetmask(3), setjmp(3), siginterrupt(3), sigsetops(3),
     ucontext(3), tty(4)