sigaltstack

å称
     sigaltstack — ã·ã°ãã«ã¹ã¿ãã¯ã³ã³ããã¹ãã®è¨å®ãå¥æ

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

æ¸å¼
     <signal.h>

     typedef struct sigaltstack {
             char    *ss_sp;
             size_t  ss_size;
             int     ss_flags;
     } stack_t;
     int sigaltstack(const stack_t * restrict ss, stack_t * restrict oss)

解説
     sigaltstack()
     ã·ã¹ãã ã³ã¼ã«ã使ç¨ãããã¨ã«ãããã¦ã¼ã¶ã¯ã·ã°ãã«ãå¦çããå¥ã®ã¹ã¿ãã¯ã
     å®ç¾©ã§ãã¾ãã ss ã 0 ã§ãªãå ´åãã·ã°ãã«ãéä¿¡ãã ã·ã°ãã«ã¹ã¿ãã¯
     ã¸ã®ãã¤ã³ã¿ã¨ãµã¤ãºãæå®ãããããã»ã¹ããã®ã¹ã¿ãã¯ã§ åä½ä¸‐
     ã§ãããã©ãããã·ã¹ãã ã«ä¼ãããã¾ãã ãã³ãã©ãã·ã°ãã«ã¹ã¿ãã¯ã§åä½ããå¿è¦ããããã¨ã
     ã·ã°ãã«ã®ã¢ã¯ã·ã§ã³ã示ãå ´å ( sigaction(2)
     ã·ã¹ãã ã³ã¼ã«ã§æå®)ãã·ã¹ãã ã¯ãããã»ã¹ããã®ã¹ã¿ãã¯ã§ åä½ä¸‐
     ã§ãããã©ããããã§ãã¯ãã¾ãã ããã»ã¹ãã·ã°ãã«ã¹ã¿ãã¯ã§åä½ãã¦ããªãå ´åãã·ã¹ãã ã¯ã
     ã·ã°ãã«ãã³ãã©ã®åä½ä¸ã¯ã·ã°ãã«ã¹ã¿ãã¯ãé©åãªãã®ã«åãæ¿ãã¾ãã

     SS_DISABLE ã ss_flags ã§è¨å®ããã¦ããã¨ã ss_sp 㨠ss_size
     ã¯ç¡è¦ããã¦ã·ã°ãã«ã¹ã¿ãã¯ã¯ç¡å¹ã«ãªãã¾ãã
     ã¢ã¯ãã£ããªã¹ã¿ãã¯ãç¡å¹ã«ãããã¨ããã¨ã sigaltstack() 㯠-1 ãæ»ã errno ã
     EINVAL ã«è¨å®ãã¾ãã ã¹ã¿ãã¯ãç¡å¹ã«ãªãã¨ããã¹ã¦ã®ã·ã°ãã«ã¯é常ã®
     ã¦ã¼ã¶ã¹ã¿ãã¯ã§åä½ããããã«ãªãã¾ãã
     ã¹ã¿ãã¯ãå¾ã§æå¹ã«ãã¨ã代æ¿ã¹ã¿ãã¯ã§å¦çããããã«æå®ããã
     ãã¹ã¦ã®ã·ã°ãã«ã¯ããã®æå®ã©ããã«åéããã¾ãã

     oss ã 0 以å¤ã«ããã¨ãç¾å¨ã®ã·ã°ãã«ã¹ã¿ãã¯ã®ç¶æãæ»ããã¾ãã ss_flags
     ãã£ã¼ã«ãã®å¤ã¯ãããã»ã¹ãç¾å¨ã·ã°ãã«ã¹ã¿ãã¯ã«ããå ´å㯠SS_ONSTACK
     ã«ãã·ã°ãã«ã¹ã¿ãã¯ãç¾å¨ç¡å¹ã§ããå ´å㯠SS_DISABLE ã«ãªãã¾ãã

注
     å¤ SIGSTKSZ ã¯ã代æ¿ã¹ã¿ãã¯é åãå²ãå½ã¦ãä¸è¬çãªã±ã¼ã¹ã§ä½¿ç¨ãã ãã¤ãæ° /
     æåæ°ã«å®ç¾©ããã¾ãã
     代æ¿ã¹ã¿ãã¯ã®å²ãå½ã¦ã«ã¯ãä¸è¬çã«ä»¥ä¸ã®ãããªã³ã¼ãã使ç¨ããã¾ãã

           if ((sigstk.ss_sp = malloc(SIGSTKSZ)) == NULL)
                   /* error return */
           sigstk.ss_size = SIGSTKSZ;
           sigstk.ss_flags = 0;
           if (sigaltstack(&sigstk,0) < 0)
                   perror("sigaltstack");
     ããã©ã«ããµã¤ãºä»¥å¤ã®ç¹å®éã®ã¹ã¿ãã¯ã¹ãã¼ã¹ãå¿è¦ã¨ãã
     ã·ã°ãã«ãã³ãã©ã使ç¨ããããã°ã©ã ã§ã¯ãå¥ã®æ¹æ³ã使ç¨ã§ãã¾ãã å¤ MINSIGSTKSZ
     ã¯ã代æ¿ã¹ã¿ãã¯ã®å®è¡ã«ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ã å¿è¦ã¨ãããã¤ãæ° / æå‐
     æ°ã«å®ç¾©ããã¦ãã¾ãã 代æ¿ã¹ã¿ãã¯ã®ãµã¤ãºãç®åºããå ´åã¯ããã‐
     ã°ã©ã ã§ã¹ã¿ãã¯è¦ä»¶ã« MINSIGSTKSZ
     ã追å ãããªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ã®ãªã¼ããããã許容ããå¿è¦ãããã¾ãã

     ã·ã°ãã«ã¹ã¿ãã¯ã¯ãã¹ã¿ãã¯ã®æ¡å¤§å¾åã¨ã¢ã©ã¤ã³ã¡ã³ãè¦ä»¶ã«å¾ã£ã¦
     èªåçã«èª¿æ´ããã¾ãã ã·ã°ãã«ã¹ã¿ãã¯ã¯ããã¼ãã¦ã§ã¢ã§ä¿è·ããããã¨ããããªããã¨ãããã
     é常ã®ã¹ã¿ãã¯ã®ããã«èªåçã« ``æ¡å¤§'' ãã¾ããã ã¹ã¿ãã¯ããªã¼ããã‐
     ã¼ããã¹ãã¼ã¹ãä¿è·ããã¦ããªãå ´åã¯ã äºæãã¬çµæã¨ãªããã¨ãããã¾ãã

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

ã¨ã©ã¼
     以ä¸ã®ãã¡ 1 ã¤ãçºçããã¨ã sigaltstack()
     ã·ã¹ãã ã³ã¼ã«ã¯å¦çã失æããã·ã°ãã«ã¹ã¿ãã¯ã³ã³ããã¹ãã¯å¤æ´ãããã« æ®ãã¾ãã

     [EFAULT]           ss ã oss ãããã‐
                        ã»ã¹ã¢ãã¬ã¹ç©ºéã®æå¹ãªé¨åã§ãªãã¡ã¢ãªãæãã¦ãã¾ãã

     [EINVAL]           ã¢ã¯ãã£ããªã¹ã¿ãã¯ãç¡å¹ã«ãããã¨ãã¾ããã

     [ENOMEM]           代æ¿ã¹ã¿ãã¯é åã®ãµã¤ãºã MINSIGSTKSZ
                        以ä¸ã«ãªã£ã¦ãã¾ãã

é¢é£é ç®
     sigaction(2), setjmp(3)

æ´å²
     sigaltstack() ã®åãã¼ã¸ã§ã³ã§ãã sigstack() ã·ã¹ãã ã³ã¼ã«ã¯ 4.2BSD
     ã§ç»å ´ãã¾ããã