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);
signum ´Â ½Ã±×³ÎÀ» °¡¸®Å°¸ç, SIGKILL °ú SIGSTOP ¸¦ Á¦¿ÜÇÑ ¸ðµç ½Ã±×³Î °ªÀÌ µÉ ¼ö ÀÖ´Ù.
act °¡ nullÀÌ ¾Æ´Ò ¶§, ½Ã±×³Î signum ¿¡ ´ëÇÑ »õ·Î¿î ¾×¼ÇÀº act °¡ µÇ¸ç, oldact ÀÌ nullÀÌ ¾Æ´Ò ¶§, ±âÁ¸ÀÇ ¾×¼ÇÀº oldact ¿¡ ÀúÀåµÈ´Ù.
sigaction ±¸Á¶´Â ´ÙÀ½°ú °°ÀÌ Á¤ÀǵȴÙ.
struct sigaction { void (*sa_handler)(int); void (*sa_sigaction)(int, siginfo_t *, void *); sigset_t sa_mask; int sa_flags; void (*sa_restorer)(void); }
¾ÆÅ°ÅØÃÄ¿¡ µû¶ó °ø¿ëü·Î µÇ¾î Àֱ⵵ ÇϹǷÎ, sa_handler ¿Í sa_sigaction À» ¸ðµÎ ÁöÁ¤ÇÏÁö ¸»¶ó.
sa_restorer ¿ä¼Ò´Â ¾²ÀÌÁö ¾ÊÀ¸¸ç, »ç¿ëµÇ¾î¼´Â ¾ÈµÈ´Ù. POSIX´Â sa_restorer ¿ä¼Ò¸¦ °®Áö ¾Ê´Â´Ù.
sa_handler ´Â signum ½Ã±×³ÎÀÌ ¿À¸é ½ÇÇàµÇ´Â ¾×¼ÇÀ» ¸í½ÃÇϸç, µðÆúÆ® ¾×¼ÇÀ» ÃëÇ϶ó´Â SIG_DFL , ½Ã±×³ÎÀ» ¹«½ÃÇ϶ó´Â SIG_IGN , ½Ã±×³ÎÀ» ó¸®Çϴ ƯÁ¤ ÇÔ¼ö¿¡ ´ëÇÑ Æ÷ÀÎÅÍ ÁßÀÇ Çϳª°¡ µÉ ¼ö ÀÖ´Ù. ¼¼¹ø°ÀÇ °æ¿ì ½Ã±×³Î ó¸® ÇÔ¼ö´Â ½Ã±×³Î ¹øÈ£¸¸À» À¯ÀÏÇÑ Àμö·Î °®´Â´Ù.
sa_sigaction ¶ÇÇÑ signum ½Ã±×³Î°ú ¿¬°áµÈ ¾×¼ÇÀ» ¸í½ÃÇÑ´Ù. ó¸® ÇÔ¼ö´Â ½Ã±×³Î ¹øÈ£¸¦ ù¹ø° Àμö·Î, siginfo_t ¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ µÎ¹ø° Àμö·Î, ±×¸®°í voidÇü Æ÷ÀÎÅͷΠij½ºÆ®µÈ ucontext_t ¿¡ ´ëÇÑ Æ÷ÀÎÅ͸¦ ¼¼¹ø° Àμö·Î °®´Â´Ù.
sa_mask ´Â ½Ã±×³Î Çڵ鷯ÀÇ ½ÇÇà µ¿¾È ºí·ÏȵǾî¾ß ÇÏ´Â ½Ã±×³ÎÀÇ ¸¶½ºÅ©¸¦ Á¦°øÇÑ´Ù. ¶ÇÇÑ, SA_NODEFER ¶Ç´Â SA_NOMASK ÀÌ »ç¿ëµÇÁö ¾ÊÀ¸¸é, Çڵ鷯¸¦ ½Ãµ¿½ÃÄ×´ø ±× ½Ã±×³Îµµ ºí·ÏȵȴÙ.
sa_flags ´Â ½Ã±×³Î ó¸® ÇÁ·Î¼¼½ºÀÇ ÇàÀ§¸¦ º¯°æ½ÃÅ°´Â ÀÏ·ÃÀÇ Ç÷¡±×µéÀ» ¸í½ÃÇÑ´Ù. ÀÌ´Â bitwise ȤÀº Ç÷¡±×´Â ¾Æ·¡ Ç÷¡±× µéÀÇ 0°³ ÀÌ»óÀÇ OR ºñÆ® ¿¬»êÀ¸·Î ¸¸µé¾îÁø´Ù.
sa_sigaction ÀÇ siginfo_t º¯¼ö´Â ´ÙÀ½ÀÇ ¿ä¼ÒµéÀ» °®´Â ±¸Á¶Ã¼(struct)ÀÌ´Ù.
siginfo_t { int si_signo; /* ½Ã±×³Î ³Ñ¹ö */ int si_errno; /* errno °ª */ int si_code; /* ½Ã±×³Î ÄÚµå */ pid_t si_pid; /* ÇÁ·Î¼¼½º ID º¸³»±â */ uid_t si_uid; /* ÇÁ·Î¼¼½º¸¦ Àü¼ÛÇÏ´Â ½ÇÁ¦ »ç¿ëÀÚ ID */ int si_status; /* Exit °ª ¶Ç´Â ½Ã±×³Î */ clock_t si_utime; /* ¼Ò¸ðµÈ »ç¿ëÀÚ ½Ã°£ */ clock_t si_stime; /* ¼Ò¸ðµÈ ½Ã½ºÅÛ ½Ã°£ */ sigval_t si_value; /* ½Ã±×³Î °ª */ int si_int; /* POSIX.1b ½Ã±×³Î */ void * si_ptr; /* POSIX.1b ½Ã±×³Î */ void * si_addr; /* ½ÇÆи¦ ÃÊ·¡ÇÑ ¸Þ¸ð¸® À§Ä¡ */ int si_band; /* ¹êµå À̺¥Æ® */ int si_fd; /* ÆÄÀÏ ±â¼úÀÚ */ }
si_signo, si_errno ±×¸®°í si_code ´Â ¸ðµç ½Ã±×³Î¿¡ ´ëÇØ Á¤ÀǵǾú´Ù. kill(2), POSIX.1b ½Ã±×³Î°ú SIGCHLDÀº si_pid °ú si_uid À» ä¿î´Ù. SIGCHLD Àº ¶ÇÇÑ si_status, si_utime, si_stime À» ä¿î´Ù. si_int ±×¸®°í si_ptr ´Â POSIX.1b ½Ã±×³ÎÀÇ ¼Û½ÅÀÚ¿¡ ÀÇÇØ ¸í½ÃµÈ´Ù. Á»´õ ÀÚ¼¼ÇÑ »çÇ×À» º¸·Á¸é, sigqueue(2) À» ÂüÁ¶Ç϶ó. SIGILL, SIGFPE, SIGSEGV ±×¸®°í SIGBUSÀº si_addr ¸¦ ¿À·ùÀÇ ÁּҷΠä¿î´Ù. SIGPOLL Àº si_band¿Ísi_fd ¸¦ ä¿î´Ù. si_code ´Â ¿Ö ½Ã±×³ÎÀÌ º¸³»Á³´ÂÁö¿¡ ´ëÇØ Áö½ÃÇÑ´Ù. ÀÌ´Â bitmask°¡ ¾Æ´Ñ °ªÀÌ´Ù. ³ª¿Ã ¼ö ÀÖ´Â ¸ðµç ½Ã±×³Î °ªÀº ÀÌ Å×ÀÌºí¿¡ ³ª¿µÇ¾î ÀÖ´Ù.
si_code | |
Value | Signal origin |
SI_USER | kill, sigsend or raise |
SI_KERNEL | The kernel |
SI_QUEUE | sigqueue |
SI_TIMER | timer expired |
SI_MESGQ | mesq state changed |
SI_ASYNCIO | AIO completed |
SI_SIGIO | queued SIGIO |
SIGILL | |
ILL_ILLOPC | illegal opcode |
ILL_ILLOPN | illegal operand |
ILL_ILLADR | illegal addressing mode |
ILL_ILLTRP | illegal trap |
ILL_PRVOPC | privileged opcode |
ILL_PRVREG | privileged register |
ILL_COPROC | coprocessor error |
ILL_BADSTK | internal stack error |
SIGFPE | |
FPE_INTDIV | integer divide by zero |
FPE_INTOVF | integer overflow |
FPE_FLTDIV | floating point divide by zero |
FPE_FLTOVF | floating point overflow |
FPE_FLTUND | floating point underflow |
FPE_FLTRES | floating point inexact result |
FPE_FLTINV | floating point invalid operation |
FPE_FLTSUB | subscript out of range |
SIGSEGV | |
SEGV_MAPERR | address not mapped to object |
SEGV_ACCERR | invalid permissions for mapped object |
SIGBUS | |
BUS_ADRALN | invalid address alignment |
BUS_ADRERR | non-existant physical address |
BUS_OBJERR | object specific hardware error |
SIGTRAP | |
TRAP_BRKPT | process breakpoint |
TRAP_TRACE | process trace trap |
SIGCHLD | |
CLD_EXITED | child has exited |
CLD_KILLED | child was killed |
CLD_DUMPED | child terminated abnormally |
CLD_TRAPPED | traced child has trapped |
CLD_STOPPED | child has stopped |
CLD_CONTINUED | stopped child has continued |
SIGPOLL | |
POLL_IN | data input available |
POLL_OUT | output buffers available |
POLL_MSG | input message available |
POLL_ERR | i/o error |
POLL_PRI | high priority input available |
POLL_HUP | device disconnected |
sigprocmask È£ÃâÀº ÇöÀç ºí·ÏÈµÈ ½Ã±×³ÎµéÀ» º¯°æ½ÃÅ°´Âµ¥ »ç¿ëµÈ´Ù. È£ÃâÀº ÁöÁ¤µÈ how °ª¿¡ µû¶ó ´Ù¸£°Ô µ¿ÀÛÇÑ´Ù.
oldset ÀÌ nullÀÌ ¾Æ´Ò ¶§, ±âÁ¸ÀÇ ¸¶½ºÅ© ½Ã±×³Î ÁýÇÕÀº oldset ¿¡ ÀúÀåµÈ´Ù.
sigpending È£ÃâÀº ºí·ÏÈ¿¡ ¸·Çô ±â´Ù¸®°í ÀÖ´Â ½Ã±×³ÎÀ» »ìÆ캼 ¼ö ÀÖµµ·Ï ÇØÁØ´Ù. ±â´Ù¸®´Â ½Ã±×³ÎµéÀÇ ½Ã±×³Î ¸¶½ºÅ©´Â set ³»¿¡ ÀúÀåµÈ´Ù.
sigsuspend È£ÃâÀº ÇÁ·Î¼¼½º°¡ ¸·°í ÀÖ´Â ½Ã±×³Î ¸¶½ºÅ©¸¦ ÁöÁ¤ÇÑ mask ·Î Àá½Ã ´ëüÇÏ°í, ´ÙÀ½ ½Ã±×³ÎÀÌ ¼ö½ÅµÉ ¶§±îÁö ÇÁ·Î¼¼½º¸¦ ÁßÁö½ÃŲ´Ù.
POSIX¿¡ µû¸£¸é, ÇÁ·Î¼¼½º°¡ kill() ¶Ç´Â raise() ÇÔ¼ö°¡ ¸¸µé¾î ³½ °ÍÀÌ ¾Æ´Ñ GFPE, SIGILL, ȤÀº SIGSEGV¸¦ ¹«½ÃÇÑ ÀÌÈÄÀÇ ÇÁ·Î¼¼½ºÀÇ µ¿ÀÛÀº Á¤ÀǵÇÁö ¾Ê´Â´Ù. Á¤¼ö¸¦ 0À¸·Î ³ª´« °á°ú ¶ÇÇÑ Á¤ÀǵÇÁö ¾Ê´Â´Ù. ÀϺΠ¾ÆÅ°ÅØÃÄ¿¡¼± 0À¸·Î ³ª´©±â°¡ SIGFPE ½Ã±×³ÎÀ» ¸¸µé¾î ³¾ °ÍÀÌ´Ù. (¶ÇÇÑ °¡Àå Å« À½ÀÇ Á¤¼ö¸¦ -1·Î ³ª´©¾îµµ SIGFPE¸¦ »ý¼ºÇÒ ¼ö ÀÖ´Ù.) ÀÌ ½Ã±×³ÎÀ» ¹«½ÃÇÏ¸é ¹«ÇÑ ·çÇÁ¸¦ ÃÊ·¡ÇÒ ¼ö ÀÖ´Ù.
POSIX ½ºÆåÀº ¿ÀÁ÷ SA_NOCLDSTOP ¸¸À» Á¤ÀÇÇÑ´Ù . ´Ù¸¥ sa_flags ÀÇ »ç¿ëÀº À̽ÄÀÌ ºÒ°¡´ÉÇÏ´Ù.
SA_RESETHAND Ç÷¡±×´Â µ¿ÀÏÇÑ À̸§ÀÇ SVr4 Ç÷¡±×¿Í ȣȯ°¡´ÉÇÏ´Ù.
SA_NODEFER Ç÷¡±×´Â Ä¿³Î 1.3.9°ú »õ·Î¿î ¹öÀüÇÏ¿¡¼ µ¿ÀÏÇÑ À̸§ÀÇ SVr4 Ç÷¡±×¿Í ȣȯ°¡´ÉÇÏ´Ù.
SVr4 ȣȯ¼ºÀ» À§ÇÑ SA_RESETHAND ¿Í SA_NODEFER À̸§µéÀº ¿ÀÁ÷ ¶óÀ̺귯¸® ¹öÀü 3.0.9 ±×¸®°í ±× ÀÌÈÄÀÇ ¹öÀü¿¡¼¸¸ Á¸ÀçÇÑ´Ù.
SA_SIGINFO Ç÷¡±×´Â POSIX.1b¿¡ ÀÇÇؼ¸¸ ¸í½ÃµÈ´Ù. ÀÌ¿¡ ´ëÇÑ Áö¿øÀº ¸®´ª½º 2.2¿¡ Ãß°¡µÇ¾ú´Ù.
sigaction ÇöÀç ½Ã±×³Î Ã³¸®±â¿¡ Äõ¸®¸¦ Çϱâ À§ÇØ ³Î µÎ¹ø° Àμö·Î È£ÃâµÉ ¼ö ÀÖ´Ù. À̸¦ ³Î µÎ¹ø° ±×¸®°í ¼¼¹ø° Àμöµé·Î À̸¦ È£ÃâÇÔÀ¸·Î¼ ÇöÀç ¸Ó½Å¿¡ ´ëÇÑ ÁÖ¾îÁø ½Ã±×³ÎÀÌ Å¸´çÇÑ°¡¸¦ üũÇϴµ¥ »ç¿ëµÉ ¼ö ÀÖ´Ù.
½Ã±×³Î ü°è Á¶ÀÛ¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ Á¤º¸¸¦ ¾òÀ¸·Á¸é, sigsetops(3) À» ÂüÁ¶Ç϶ó.