SIGACTION

Section: Linux Programmer's Manual (2)
Updated: 8 May 1999
Index
Return to Main Contents
 

À̸§

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);  

¼³¸í

The sigaction ½Ã½ºÅÛ È£ÃâÀº ƯÁ¤ ½Ã±×³ÎÀÇ ¼ö½Å »ó¿¡¼­ ÇÁ·Î¼¼½º¿¡ ÀÇÇØ ÃëÇØÁø ¾×¼ÇÀ» º¯°æÇϴµ¥ »ç¿ëµÈ´Ù.

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_NOCLDSTOP
¸¸ÀÏ signum SIGCHLD, ÀÌ ÀÚ½Ä ÇÁ·Î¼¼½º°¡ ÁßÁöµÇ¾úÀ»¶§, ÀÌ Åë°í¸¦ ¼ö½ÅÇÏÁö ¸øÇϸé,
 (¿¹¸¦ µé¾î, ÀڽĠÇÁ·Î¼¼½ºµéÀÌ  SIGSTOP, SIGTSTP, SIGTTIN ¶Ç´Â SIGTTOUÀ»¼ö½ÅÇÒ¶§)
SA_ONESHOT ¶Ç´Â SA_RESETHAND
ÀÏ´Ü ½Ã±×³Î 󸮱Ⱑ È£ÃâµÇ¸é, µðÆúÆ® »óÅ¿¡ ´ëÇÑ ½Ã±×³Î ¾×¼ÇÀ» ÀçÀúÀåÇÑ´Ù. (ÀÌ´Â .BR signal (2) È£Ãâ¿¡ ´ëÇÑ ±âº» ÇàÀ§ÀÌ´Ù.)
SA_RESTART
ÀϺΠ½Ã½ºÅÛ È£ÃâµéÀÌ ½Ã±×³ÎÀ» ÅëÇØ Àç½ÃÀÛÇÒ ¼ö ÀÖµµ·Ï ÇÔÀ¸·Î¼­ BSD ½Ã±×³Î ÀÇ¹Ì¿Í È£È¯µÇ´Â ÇàÀ§¸¦ Á¦°øÇÑ´Ù.
SA_NOMASK or SA_NODEFER
½Ã±×³ÎÀÌ ÀÚü ½Ã±×³Î 󸮱â·ÎºÎÅÍ ¼ö½Å¹ÞÁö ¾Êµµ·Ï ÇÑ´Ù.
SA_SIGINFO
The signal handler takes 3 arguments, not one. In this case, should be set instead of ½Ã±×³Î 󸮱â´Â Çϳª°¡ ¾Æ´Ñ, 3°³ÀÇ Àμö¸¦ ÃëÇÑ´Ù. ÀÌ °æ¿ì, sa_handler´ë½Å¿¡.Isa_sigactionÀ̼³Á¤µÇ¾î¾ßÇÑ´Ù. (sa_sigaction Çʵå´Â ¸®´ª½º 2.1.86¿¡¼­ Ãß°¡µÇ¾ú´Ù.)

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_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½Ã±×³ÎÀǼ۽ÅÀÚ¿¡ÀÇÇظí½ÃµÈ´Ù. Á»´õ ÀÚ¼¼ÇÑ »çÇ×À» º¸·Á¸é, 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 È£ÃâÀº ÇöÀç ºí·ÏÈ­µÈ ½Ã±×³ÎµéÀ» º¯°æ½ÃÅ°´Âµ¥ »ç¿ëµÈ´Ù. È£ÃâÀÇ ÇàÀ§´Â ¾î¶»°Ô Çϴ°¡¿¡ µû¸¥ °ª¿¡ ÀÇÁ¸ÀûÀÌ´Ù.

SIG_BLOCK
ÀÏ·ÃÀÇ ºí·ÏÈ­µÈ ½Ã±×³ÎµéÀº ÇöÀç ¼³Á¤°ú .I set ÀμöÀÇ ÇÕÀÌ´Ù.
SIG_UNBLOCK
The signals in set ³»ÀÇ ½Ã±×³ÎµéÀº ÇöÀç ÀÏ·ÃÀÇ ºí·ÏÈ­µÈ ½Ã±×³Îµé¿¡¼­ »èÁ¦µÈ´Ù. ºí·ÏÈ­µÇÁö ¾ÊÀº ½Ã±×³Î¿¡ ´ëÇØ ºí·ÏÈ­ÇÏÁö ¾Ê´Â°ÍÀÌ Å¸´çÇÏ´Ù.
SIG_SETMASK
ºí·ÏÈ­µÈ ½Ã±×³ÎµéÀÇ ¼³Á¤Àº Àμö .IR set À¸·Î ¼³Á¤µÈ´Ù.

If oldset ´Â -nullÀÌ ¾Æ´Ï°í, ½Ã±×³Î ¸¶½ºÅ©ÀÇ ÀÌÀü °ªÀº .IR oldset ³»¿¡ ÀúÀåµÈ´Ù.

The sigpending È£ÃâÀº Àü´Þ ½Ã±×³Îµé¿¡ ´ëÇÑ °Ë»ç¸¦ Çã¿ëÇÑ´Ù. Àü´Þ ½Ã±×³ÎµéÀÇ ½Ã±×³Î ¸¶½ºÅ©´Â set³»¿¡ÀúÀåµÈ´Ù.

sigsuspend È£ÃâÀº ÀϽÃÀûÀ¸·Î ½Ã±×³Î ¸¶½ºÅ©¸¦ .I mask¿¡ ÀÇÇØ ÁÖ¾îÁø ÇÁ·Î¼¼½ºµé·Î ´ëüÇÏ°í, ½Ã±×³ÎÀÌ ¼ö½ÅµÉ¶§±îÁö ÇÁ·Î¼¼½º¸¦ ÁßÁö½ÃŲ´Ù.  

¹Ýȯ°ª

sigaction, sigprocmask, sigpending ±×¸®°í sigsuspend Àº ¼º°øÇϸé 0À» ½ÇÆÐÇϸé -1À» ¸®ÅÏÇÑ´Ù.  

¿¡·¯

EINVAL
ºÎÀûÀýÇÑ ½Ã±×³ÎÀÌ ÁöÁ¤µÇ¾ú´Ù. °¨ÁöµÇÁö ¾Ê´Â .BR SIGKILL " ¶Ç´Â " SIGSTOP¿¡ ´ëÇÑ ¾×¼ÇÀ» º¯°æÇÏ°íÀÚ ÇÑ´Ù¸é, .B EINVALÀÌ ¶ÇÇÑ »ý¼ºµÉ °ÍÀÌ´Ù.
EFAULT
act, oldact, set ¶Ç´Â oldset ´Â ÇÁ·Î¼¼½º ÁÖ¼Ò ¿µ¿ª Áß Å¸´çÇÏÁö ¾ÊÀº ºÎºÐÀÎ ¸Þ¸ð¸®¸¦ °¡¸®Å²´Ù.
EINTR
½Ã½ºÅÛ È£ÃâÀÌ ÀÎÅÍ·´Æ®µÇ¾ú´Ù.
 

ÁÖÀÇ

sigprocmask È£Ãâ·Î .BR SIGKILL " ¶Ç´Â " SIGSTOPÀ» ºí·ÏÈ­ÇÏ´Â °ÍÀº ºÒ°¡´ÉÇÏ´Ù. ÀÌ·¯ÇÑ ½Ãµµ´Â ¹«½ÃµÈ´Ù.

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)À» ÂüÁ¶Ç϶ó.  

ȣȯ

POSIX, SVr4. SVr4 ´Â EINTR Á¶°Ç¿¡ ´ëÇÑ ¹®¼­¸¦ Á¦°øÇÏÁö ¾Ê´Â´Ù.  

°ü·Ã Ç׸ñ

kill(1), kill(2), killpg(2), pause(2), raise(3), siginterrupt(3), signal(2), signal(7), sigsetops(3), sigvec(2)  

¿ªÀÚ

ASPLINUX<man@asp-linux.co.kr>, 2000³â 7¿ù 29ÀÏ


 

Index

À̸§
»ç¿ë¹ý
¼³¸í
¹Ýȯ°ª
¿¡·¯
ÁÖÀÇ
ȣȯ
°ü·Ã Ç׸ñ
¿ªÀÚ

This document was created by man2html, using the manual pages.
Time: 08:07:01 GMT, March 25, 2004