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ÀÌ ¾Æ´Ï¶ó¸é ½Ã±×³Î.I signum¿¡ ´ëÇÑ »õ·Î¿î ¾×¼ÇÀº .IR act¿¡¼ ¼³Ä¡µÈ´Ù. ¸¸ÀÏ oldact ÀÌ -nullÀÌ ¾Æ´Ï¶ó¸é, ÀÌÀüÀÇ ¾×¼ÇÀº .IR 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_restorer ¿ä¼Ò´Â ¾È ¾²ÀÌ´Â °ÍÀ̾î¼, »ç¿ëµÇ¾î¼´Â ¾ÈµÈ´Ù. POSIX´Â .I sa_restorer¿ä¼Ò¸¦ ¸í½ÃÇÒ ¼ö ¾ø´Ù.
sa_handler ´Â .I signum¿Í °ü·ÃµÈ ¾×¼ÇÀ» ¸í½ÃÇÏ°í, µðÆúÆ® ¾×¼Ç¿¡ ´ëÇØ ÀÌ ½Ã±×³ÎÀ» ¹«½ÃÇϱâ À§ÇÑ SIG_DFL ¶Ç´Â SIG_IGN À̰ųª, ½Ã±×³Î ó¸® ÇÔ¼ö¿¡ ´ëÇÑ Áö½ÃÀÚ°¡ µÉ ¼ö ÀÖ´Ù.
sa_mask gives a mask of signals which should be blocked during execution of the signal handler. In addition, the signal which triggered the handler will be blocked, unless the ´Â ½Ã±×³Î 󸮱âÀÇ ½ÇÇà µ¿¾È ºí·ÏȵǾî¾ß ÇÏ´Â ½Ã±×³ÎÀÇ ¸¶½ºÅ©¸¦ Á¦°øÇÑ´Ù. °Ô´Ù°¡, .B SA_NODEFER ¶Ç´Â SA_NOMASKÀÌ »ç¿ëµÇÁö ¾ÊÀ¸¸é, Çڵ鷯¸¦ ½Ãµ¿½ÃÅ°´Â ½Ã±×³ÎÀº ºí·ÏȵȴÙ.
sa_flags ´Â ½Ã±×³Î ó¸® ÇÁ·Î¼¼½ºÀÇ ÇàÀ§¸¦ ¼öÁ¤ÇÏ´Â ÀÏ·ÃÀÇ Ç÷¡±×µéÀ» ¸í½ÃÇÑ´Ù. ÀÌ´Â bitwise ȤÀº zero ȤÀº ´ÙÀ½ Áß ±× ÀÌ»óÀÇ °Íµé¿¡ ÀÇÇØ Çü¼ºµÈ´Ù.
sa_sigaction¿¡ ´ëÇÑ .I siginfo_t º¯¼ö´Â ´ÙÀ½ÀÇ ¿ä¼ÒµéÀ» Áö´Ñ ±¸Á¶Ã¼(struct)ÀÌ´Ù.
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_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 È£ÃâÀº ÇöÀç ºí·ÏÈµÈ ½Ã±×³ÎµéÀ» º¯°æ½ÃÅ°´Âµ¥ »ç¿ëµÈ´Ù. È£ÃâÀÇ ÇàÀ§´Â ¾î¶»°Ô Çϴ°¡¿¡ µû¸¥ °ª¿¡ ÀÇÁ¸ÀûÀÌ´Ù.
If oldset ´Â -nullÀÌ ¾Æ´Ï°í, ½Ã±×³Î ¸¶½ºÅ©ÀÇ ÀÌÀü °ªÀº .IR oldset ³»¿¡ ÀúÀåµÈ´Ù.
The sigpending È£ÃâÀº Àü´Þ ½Ã±×³Îµé¿¡ ´ëÇÑ °Ë»ç¸¦ Çã¿ëÇÑ´Ù. Àü´Þ ½Ã±×³ÎµéÀÇ ½Ã±×³Î ¸¶½ºÅ©´Â set³»¿¡ÀúÀåµÈ´Ù.
sigsuspend È£ÃâÀº ÀϽÃÀûÀ¸·Î ½Ã±×³Î ¸¶½ºÅ©¸¦ .I mask¿¡ ÀÇÇØ ÁÖ¾îÁø ÇÁ·Î¼¼½ºµé·Î ´ëüÇÏ°í, ½Ã±×³ÎÀÌ ¼ö½ÅµÉ¶§±îÁö ÇÁ·Î¼¼½º¸¦ ÁßÁö½ÃŲ´Ù.
POSIX¿¡ ÀÇÇϸé, ÇÁ·Î¼¼½ºÀÇ ÇàÀ§´Â kill() ¶Ç´Â raise() ÇÔ¼öµé¿¡ ÀÇÇØ »ý¼ºµÇÁö ¾Ê´Â GFPE, SIGILL, ¶Ç´Â SIGSEGV¸¦ ¹«½ÃÇÑ ÈÄ¿¡´Â ¸·¿¬ÇØÁø´Ù. Á¦·Î¿¡ ÀÇÇÑ Á¤¼ö(Integer) ³ª´©±â´Â ¸·¿¬ÇÑ °á°ú¸¦ °®´Â´Ù. ÀϺΠ¾ÆÅ°ÅØÃÄ¿¡¼, ÀÌ´Â SIGFPE ½Ã±×³ÎÀ» »ý¼ºÇÒ °ÍÀÌ´Ù. (¶ÇÇÑ À½¼ö Á¤¼ö(integer)¸¦ -1·Î ³ª´©¸é SIGFPE¸¦ »ý¼ºÇÒ ¼öµµ ÀÖ´Ù ) ÀÌ ½Ã±×³ÎÀ» ¹«½ÃÇÏ¸é ¹«ÇÑ ·çÇÁ¸¦ ÃÊ·¡ÇÒ ¼ö ÀÖ´Ù.
The POSIX ½ºÆåÀº ¿ÀÁ÷ .BR 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 ÇöÀç ½Ã±×³Î Ã³¸®±â¿¡ Äõ¸®¸¦ Çϱâ À§ÇØ ³Î µÎ¹ø° Àμö·Î È£ÃâµÉ ¼ö ÀÖ´Ù. À̸¦ ³Î µÎ¹ø° ±×¸®°í ¼¼¹ø° Àμöµé·Î À̸¦ È£ÃâÇÔÀ¸·Î¼ ÇöÀç ¸Ó½Å¿¡ ´ëÇÑ ÁÖ¾îÁø ½Ã±×³ÎÀÌ Å¸´çÇÑ°¡¸¦ üũÇϴµ¥ »ç¿ëµÉ ¼ö ÀÖ´Ù.
½Ã±×³Î ü°è Á¶ÀÛ¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ Á¤º¸¸¦ ¾òÀ¸·Á¸é, .BR sigsetops (3)À» ÂüÁ¶Ç϶ó.