sigaction

SIGACTION(2)               Linux Programmer's Manual              SIGACTION(2)



åå
       sigaction, sigprocmask, sigpending, sigsuspend - POSIX ã·ã°ãã«ã»æä½é¢æ°


æ¸å¼
       #include <signal.h>


       int sigaction(int signum, const struct sigaction *act, struct sigaction
       *oldact);

       int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);

       int sigpending(sigset_t *set);

       int sigsuspend(const sigset_t *mask);


説æ
       sigaction ã·ã¹ãã ã»ã³ã¼ã«ã¯ç¹å®ã®ã·ã°ãã«ãåãã ãã‐
       ã»ã¹ã®åä½ãå¤æ´ããã®ã«ä½¿ç¨ããã

       signum ã¯ã·ã°ãã«ãæå®ããã SIGKILL 㨠SIGSTOP
       以å¤ã®å¨ã¦ã®æå¹ãªã·ã°ãã«ãæå®ã§ããã

       act ã NULL ã§ãªããã° signum ã·ã°ãã«ã®æ°ããåä½ã¨ã㦠act ãè¨å®ãããã

       oldact ã NULL ã§ãªããã°ä»ã¾ã§ã®åä½ã oldact ã«æ ¼ç´ãããã

       sigaction æ§é ä½ã¯ä»¥ä¸ã®ããã«å®ç¾©ãããã

              struct sigaction {
                  void (*sa_handler)(int);
                  sigset_t sa_mask;
                  int sa_flags;
                  void (*sa_restorer)(void);
              }

       sa_handler 㯠signum ã«è¨å®ããåä½ãæå®ãã ããã©ã«ãã®åä½ãæå®ãã SIG_DFL ãã
       ãã®ã·ã°ãã«ãç¡è¦ãã SIG_IGN ããã·ã°ãã«ã»ãã³ãã©ã¼é¢æ°ã¸ã®ãã¤ã³ã¿ã¼ãè¨å®ããã

       sa_mask ã¯ã·ã°ãã«ã»ãã³ãã©ã¼å®è¡ä¸ã«ç¦æ¢(block)ããã¹ãã·ã°ãã«ã®ãã¹ã¯ã
       ä¸ãããå ãã¦ã SA_NODEFER ã SA_NOMASK
       ãã©ã°ã使ç¨ãããªãéãã¯ããã³ãã©ã¼ãå¼ã³åºããã·ã°ãã«ãç¦æ¢ãããã

       sa_flags ã¯ã·ã°ãã«ã»ãã³ãã©ã¼ã®åä½ãä¿®æ£ããããã®ãã©ã°ã®éåãæå®ããã
       ãã©ã°ã¯ä»¥ä¸ã®ã¼ãå以ä¸ã®ãã©ã°ã® ãããOR ã«ãã£ã¦è¡¨ç¾ãããã

              SA_NOCLDSTOP
                     signum ã SIGCHLD ã®å ´åã«ãåããã»ã¹(child process)ãåæ‐
                     ¢(stop)ããå ´å (ä¾ãã°ãåããã»ã¹ã SIGSTOP, SIGTSTP, SIGTTIN,
                     SIGTTOU ãåããå ´åãªã©) ã®å ±åãåããªãã

              SA_ONESHOT ã¾ã㯠SA_RESETHAND
                     ä¸åº¦ãã·ã°ãã«ã»ãã³ãã©ã¼ãå¼ã°ããã¨ã·ã°ãã«ã®åä½ãããã©ã«ãã«æ»ãã
                     (ãã㯠signal(2) ã·ã¹ãã ã»ã³ã¼ã«ã®ããã©ã«ãã®åä½ã¨åãã§ããã)

              SA_RESTART
                     ããã¤ãã·ã¹ãã ã»ã³ã¼ã«ãã·ã°ãã«ãè¶ãã¦åéã§ããããã«ã ããã¨ã§ BSD
                     ã·ã°ãã«ã®æ¹å¼(semantics)ã¨äºææ§ã®ããåä½ãæä¾ããã

              SA_NOMASK or SA_NODEFER
                     ããèªèº«ã®ã·ã°ãã«ã»ãã³ãã©ã¼ã®åé¨ã«ããæã§ã
                     ã·ã°ãã«ã妨害ããªãããã«ããã

       sa_restorer è¦ç´ ã¯å»æ¢(obsolete)ãããã®ã§ä½¿ç¨ãã¦ã¯ãããªãã

       sigprocmask ã³ã¼ã«ã¯ç¾å¨ç¦æ¢(block)ããã¦ããã·ã°ãã«ã®ãªã¹ããå¤æ´ããã
       ã³ã¼ã«ã®åä½ã¯ how ã®å¤ã«ä¾åã以ä¸ã®ããã«ãªãã

              SIG_BLOCK
                     ç¦æ¢ãããã·ã°ãã«ã®éåã¯ç¾å¨ã®å¤ã¨ set å¼ãæ°ã«è¨‐
                     å®ããããã®ã®åæã¨ãªãã

              SIG_UNBLOCK
                     ç¾å¨ç¦æ¢ããã¦ããã·ã°ãã«ã®éåãã set ã«ããã·ã°ãã«ãåãé¤ããç¦æ‐
                     ¢ããã¦ããªãã·ã°ãã«ãé¤ãã㨠ãã¦ãåé¡ã¯ãªãã

              SIG_SETMASK
                     ç¦æ¢ããã¦ããã·ã°ãã«ã®éåã« set å¼ãæ°ãè¨å®ããã

       oldset ã NULL ã§ãªããã°ãã·ã°ãã«ã»ãã¹ã¯ã®ä»ã¾ã§ã®å¤ã oldset ã«æ ¼ç´ããã

       sigpending ã³ã¼ã«ã¯å¾æ©(pending)ä¸ã®ã·ã°ãã«(ç¦æ¢ä¸‐
       ã«çºçããã·ã°ãã«)ã®æ¤æ»ã è¡ãªããå¾æ©ä¸ã®ã·ã°ãã«ã®ãã¹ã¯ã¯ set ã«æ ¼ç´ãããã

       sigsuspend ã³ã¼ã«ã¯ä¸æçã«ããã»ã¹ã®ã·ã°ãã«ã»ãã¹ã¯ã mask
       ã§ä¸ãããããã®ã«ç½®ãæãã ã·ã°ãã«ãåããã¾ã§ãããã»ã¹ãåæ¢(suspend)ããã


è¿ãå¤
       sigaction, sigprocmask, sigpending sigsuspend ã¯æåããã° 0ãã¨ã©ã¼ãªãã° -1
       ãè¿ãã


ã¨ã©ã¼
       EINVAL ç¡å¹ãªã·ã°ãã«ãæå®ããããããã¯æç²(catch)ã§ããªã SIGKILL ã SIGSTOP
              ã®è¡åãå¤æ´ãããã¨è©¦ã¿ãå ´åã«ãçºçããã

       EFAULT act, oldact, set ã¾ã㯠oldset ã®æãã¡ã¢ãªã¼ãæ£ãããã‐
              ã»ã¹ã®ã¢ãã¬ã¹ç©ºéã«ãªãã

       EINTR  ã·ã¹ãã ã»ã³ã¼ã«ãå²è¾¼ã¾ããã


注æ
       sigprocmask ã³ã¼ã«ã§ SIGKILL ã SIGSTOP ãç¦æ‐
       ¢ãããã¨ã¯ã§ããªãããã®ãããªè©¦ã¿ã¯é»ã£ã¦ç¡è¦ãããã

       POSIX ã«ããã¨ãkill() ã raise() é¢æ°ã§çæã§ããªã SIGFPE, SIGILL, SIGSEGV
       ã·ã°ãã«ãç¡è¦(ignore)ããå¾ã®åä½ã¯æªå®ç¾©ã§ ãããã¼ã‐
       ã«ããæ´æ°å²ãç®ã®çµæã¯æªå®ç¾©ã¨ãªãã ãã種ã®ã¢ã¼ã‐
       ãã¯ãã£ã¼(architecture)ã§ã¯ãã㯠SIGFPE ã·ã°ãã«
       ãçæããããã®ã·ã°ãã«ãç¡è¦ããã¨ç¡éã«ã¼ãã«è½ã¡ãããããããªãã

       SIGCHLD ã SIG_IGN ã«è¨å®ããã¨åããã»ã¹ã®èªåçãªåãåã(reap)ãè¡ãªããã

       POSIX ã®ä»æ§ã§ã¯ SA_NOCLDSTOP ã®ã¿ãå®ç¾©ããã¦ããã ä»ã® sa_flags
       ãã©ã°ã使ç¨ãããã¨ã¯ç§»æ¤æ§(portable)ããªãã

       SA_RESETHAND ãã©ã°ã¯ SVr4 ã®åãååã®ãã©ã°ã¨äºææ§(compatible)ãããã

       The SA_NODEFER ãã©ã°ã¯ 1.3.9 以éã®ã«ã¼ãã«ã§ã¯åãååã® SVr4
       ã®ãã©ã°ã¨äºææ§ãããã ããå¤ãã«ã¼ãã«ã§ã® Linux
       ã®å®è£ã§ã¯ä¸ã¤ã ãã§ãªãå¨ã¦ã®ã·ã°ãã« åãããã¨ã許ãã¦ããã(å®éã«ã¯ sa_mask
       ã®è¨å®ã«ããç¡å¹ã«ã§ããã)

       SVr4 ã¨ã®äºææ§ã®ããã«åä»ãããã SA_RESETHAND 㨠SA_NODEFER
       ã¯ã©ã¤ãã©ãªã¼ã®ãã¼ã¸ã§ã³ 3.0.9 以éã«åå¨ããã

       sigaction ã¯ç¾å¨ã®ã·ã°ãã«ã»ãã³ãã©ã¼ã確èªããããã«äºçªç®ã®å¼ãæ°ã« NULL ã
       æå®ãã¦å¼ã³åºããã¨ãã§ãããã¾ãäºçªç®ã¨ä¸çªç®ã®å¼ãæ°ã NULL ã«ã¦
       å¼ã³åºããã¨ã«ãã£ã¦ä¸ããããã·ã°ãã«ãç¾å¨ã®ãã·ã³ã§ä½¿ãããã©ãã ãã§ãã¯ã§ããã

       ã·ã°ãã«éåã®æä½ã«é¢ãã¦ãã詳ãã㯠sigsetops(3) ãåç§ãããã¨


æºæ
       POSIX, SVr4.  SVr4 ã«ã¯ EINTR ã«ã¤ãã¦ã®è¨è¿°ã¯ãªãã


é¢é£é ç®
       kill(1), kill(2), killpg(2), pause(2), raise(3), siginterrupt(3),
       signal(2), signal(7), sigsetops(3), sigvec(2)



Linux 1.3                       24 August 1995                    SIGACTION(2)